Make lpp not be able to be usable if imported
This commit is contained in:
1 parent
0c8b5848d2
commit
7ad6c893c7
1 file changed
+34
-33
@@ -4,44 +4,45 @@ import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="A python project preparer for Linux")
|
||||
if __name__ == 'main' :
|
||||
parser = argparse.ArgumentParser(description="A python project preparer for Linux")
|
||||
|
||||
parser.add_argument('-n','--name',default='NewProject',help='The project name')
|
||||
parser.add_argument('-p','--path',default=False,help='The path to create the project in')
|
||||
parser.add_argument('-f','--filename',default='main.py',help="Initial file name")
|
||||
parser.add_argument('-g','--git',action='store_true',help='If "git init" should be used')
|
||||
parser.add_argument('-n','--name',default='NewProject',help='The project name')
|
||||
parser.add_argument('-p','--path',default=False,help='The path to create the project in')
|
||||
parser.add_argument('-f','--filename',default='main.py',help="Initial file name")
|
||||
parser.add_argument('-g','--git',action='store_true',help='If "git init" should be used')
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
if not args.path :
|
||||
path = Path().cwd()
|
||||
else :
|
||||
dest = args.path if args.path[0]!='~' else Path.home().as_posix() + args.path[1:]
|
||||
path = Path(dest)
|
||||
|
||||
if not path.exists() and path.is_file() :
|
||||
raise Exception('Path does not exist')
|
||||
|
||||
counter = 0
|
||||
|
||||
while True :
|
||||
checkablePath = args.name if counter == 0 else args.name + str(counter)
|
||||
subpath = path.joinpath(checkablePath)
|
||||
if subpath.exists() :
|
||||
counter += 1
|
||||
if not args.path :
|
||||
path = Path().cwd()
|
||||
else :
|
||||
break
|
||||
dest = args.path if args.path[0]!='~' else Path.home().as_posix() + args.path[1:]
|
||||
path = Path(dest)
|
||||
|
||||
if counter != 0 :
|
||||
path = Path(path.absolute().as_posix() + f"/{args.name}" + str(counter))
|
||||
else :
|
||||
path = Path(path.absolute().as_posix() + f"/{args.name}")
|
||||
if not path.exists() and path.is_file() :
|
||||
raise Exception('Path does not exist')
|
||||
|
||||
path.mkdir()
|
||||
counter = 0
|
||||
|
||||
file = Path(path.absolute().as_posix() + f"/{args.filename}")
|
||||
file.touch(mode=0o750)
|
||||
while True :
|
||||
checkablePath = args.name if counter == 0 else args.name + str(counter)
|
||||
subpath = path.joinpath(checkablePath)
|
||||
if subpath.exists() :
|
||||
counter += 1
|
||||
else :
|
||||
break
|
||||
|
||||
os.chdir(path.absolute())
|
||||
if args.git :
|
||||
subprocess.run(['git','init'])
|
||||
if counter != 0 :
|
||||
path = Path(path.absolute().as_posix() + f"/{args.name}" + str(counter))
|
||||
else :
|
||||
path = Path(path.absolute().as_posix() + f"/{args.name}")
|
||||
|
||||
path.mkdir()
|
||||
|
||||
file = Path(path.absolute().as_posix() + f"/{args.filename}")
|
||||
file.touch(mode=0o750)
|
||||
|
||||
os.chdir(path.absolute())
|
||||
if args.git :
|
||||
subprocess.run(['git','init'])
|
||||
Reference in new issue
Block a user