AlgorithmsSmartForce/creator.py

38 lines
1.0 KiB
Python

import argparse
from os import path, mkdir
TEXT_MAIN = "@startuml\n\nstart\n\n!include input.puml\n!include body.puml\n\nstop\n\n@enduml\n"
TEXT_COMMON = "@startuml\n\n@enduml\n"
def create_directory(directory_name: str) -> bool:
if not path.exists(directory_name):
mkdir(directory_name)
return True
else:
return False
def create_files(directory_name: str) -> None:
files = ("input.puml", "body.puml", "main.puml")
for file in files:
f = open(path.join(directory_name, file), 'w')
f.write(TEXT_MAIN) if "main" in file else f.write(TEXT_COMMON)
f.close()
def init_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="AlgorithmDigitalis")
parser.add_argument('-name', help="Algorythm name")
arguments = parser.parse_args()
return arguments
if __name__ == '__main__':
args = init_args()
dir_name = args.name
created = create_directory(directory_name=dir_name)
if created:
create_files(directory_name=dir_name)