Commit 2de1c136 authored by Bjoern Broetz's avatar Bjoern Broetz

Organize

parent a6e99340
import argparse
import os
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]
if not os.path.isdir(basedir):
print(basedir)
raise Exception
def main(basedir, target, cutdir):
if not os.path.isdir(target):
raise Exception
if cutdir not in basedir.split('/'):
raise Exception
for root, dirs, files in os.walk(basedir):
for root, dirs, files in os.walk(basedir):
rootsplit = root.split('/')
if cutdir in rootsplit:
......@@ -49,3 +30,28 @@ for root, dirs, files in os.walk(basedir):
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')
args = parser.parse_args()
basedir = os.path.abspath(args.basedir[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):
raise Exception
if cutdir not in basedir.split('/'):
raise Exception
main(basedir, target, cutdir)
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