Commit 9c90592d authored by Bjoern Broetz's avatar Bjoern Broetz

Clean up

parent 2de1c136
import argparse
import os
def main(basedir, target, cutdir):
for root, dirs, files in os.walk(basedir):
......@@ -12,10 +13,6 @@ def main(basedir, target, cutdir):
else:
nroot = root
print(root)
print(nroot)
print(dirs)
print(files)
newdir = '{0}/{1}'.format(target, nroot)
if not os.path.isdir(newdir):
os.mkdir(newdir)
......@@ -26,26 +23,47 @@ def main(basedir, target, cutdir):
os.mkdir(newdir)
for f in files:
try:
os.symlink('{0}/{1}'.format(root,f),'{0}/{1}/{2}'.format(target, nroot, f))
os.symlink('{0}/{1}'.format(root, f), '{0}/{1}/{2}'.format(
target, nroot, f))
except:
pass
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Create a link tree that mirrors a given base folder with all content. Directories are real, files are links.')
parser.add_argument('-s','--source', dest='basedir', metavar='BASEDIR', type=str, nargs=1,
help='base folder')
parser.add_argument('-t','--target', dest='target', metavar='TARGETDIR', type=str, nargs=1,
help='target folder')
parser.add_argument('-c','--cutdir', dest='cutdir', metavar='CUTDIR', type=str, nargs=1,
help='folder in the basetree from which the target tree shall start')
parser = argparse.ArgumentParser(
description=
'Create a link tree that mirrors a given base folder with all content. Directories are real, files are links.'
)
parser.add_argument(
'-s',
'--source',
dest='basedir',
metavar='BASEDIR',
type=str,
nargs=1,
help='base folder')
parser.add_argument(
'-t',
'--target',
dest='target',
metavar='TARGETDIR',
type=str,
nargs=1,
help='target folder')
parser.add_argument(
'-c',
'--cutdir',
dest='cutdir',
metavar='CUTDIR',
type=str,
nargs=1,
help='folder in the basetree from which the target tree shall start')
args = parser.parse_args()
basedir = os.path.abspath(args.basedir[0])
target = args.target[0]
cutdir = args.cutdir[0]
target = args.target[0]
cutdir = args.cutdir[0]
if not os.path.isdir(basedir):
print(basedir)
raise Exception
if not os.path.isdir(target):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment