Fix permissions and add option --mode
This commit is contained in:
parent
c406d13ce8
commit
71565142ed
|
@ -8,6 +8,7 @@ import sys
|
||||||
ap = argparse.ArgumentParser()
|
ap = argparse.ArgumentParser()
|
||||||
ap.add_argument("source")
|
ap.add_argument("source")
|
||||||
ap.add_argument("destination")
|
ap.add_argument("destination")
|
||||||
|
ap.add_argument("--mode", "-m", type=lambda x: int(x, base=8))
|
||||||
|
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
@ -22,6 +23,8 @@ with open(args.source) as inf:
|
||||||
outf.write(first_line)
|
outf.write(first_line)
|
||||||
for line in inf:
|
for line in inf:
|
||||||
outf.write(line)
|
outf.write(line)
|
||||||
|
if args.mode is not None:
|
||||||
|
os.chmod(tmp_dest, args.mode)
|
||||||
|
else:
|
||||||
|
shutil.copymode(args.source, tmp_dest)
|
||||||
os.rename(tmp_dest, args.destination)
|
os.rename(tmp_dest, args.destination)
|
||||||
|
|
||||||
shutil.copymode(args.source, args.destination)
|
|
||||||
|
|
Loading…
Reference in New Issue