From b232a562765a764158eff6132eff0fb60f465596 Mon Sep 17 00:00:00 2001 From: Srijan-SS02 Date: Mon, 19 Sep 2022 05:41:34 +0000 Subject: [PATCH] :art: Python code fromated with psf/black --- src/runner.py | 16 ++++++++------- src/script.py | 54 ++++++++++++++++++++++++++++++++++++--------------- src/writer.py | 37 +++++++++++++++++++++++++---------- tests/test.py | 2 +- 4 files changed, 75 insertions(+), 34 deletions(-) diff --git a/src/runner.py b/src/runner.py index 8820463..541c024 100644 --- a/src/runner.py +++ b/src/runner.py @@ -1,15 +1,17 @@ import os + def runner(): - if os.path.isdir('src'): + if os.path.isdir("src"): try: - os.system('pip3 install -r requirements.txt') - os.chdir('src') - os.system('python3 main.py') + os.system("pip3 install -r requirements.txt") + os.chdir("src") + os.system("python3 main.py") except: print("ERROR") else: - print('No src folder found') + print("No src folder found") + -if __name__ == '__main__': - runner() \ No newline at end of file +if __name__ == "__main__": + runner() diff --git a/src/script.py b/src/script.py index c09159c..ca9a6c6 100644 --- a/src/script.py +++ b/src/script.py @@ -10,8 +10,11 @@ def create_new_file_folder(appName: str): :param appName: Name of Your app that you want to create :return: Project file """ - os.mkdir('src') - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/main.template', 'r') as f, open('src/main.py', 'w') as fw: + os.mkdir("src") + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/main.template", + "r", + ) as f, open("src/main.py", "w") as fw: for line in f: fw.write(line) @@ -19,26 +22,41 @@ def create_new_file_folder(appName: str): def create_git_ignore(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/gitignore.template', 'r') as f, open('.gitignore', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/gitignore.template", + "r", + ) as f, open(".gitignore", "w") as fw: for line in f: fw.write(line) + def create_requirements(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/requirements.template', 'r') as f, open('requirements.txt', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/requirements.template", + "r", + ) as f, open("requirements.txt", "w") as fw: for line in f: fw.write(line) + def create_license(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/LICENSE.template', 'r') as f, open('LICENSE', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/LICENSE.template", + "r", + ) as f, open("LICENSE", "w") as fw: for line in f: fw.write(line) + def create_readme(appName: str): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/README.template', 'r') as f, open('README.md', 'w') as fw: - fw.write(f'# {appName}') + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/README.template", + "r", + ) as f, open("README.md", "w") as fw: + fw.write(f"# {appName}") fw.write("\n") for line in f: @@ -47,30 +65,32 @@ def create_readme(appName: str): def project_creator(Project_name: str): - os.mkdir(f'{Project_name}') - os.chdir(f'{Project_name}') + os.mkdir(f"{Project_name}") + os.chdir(f"{Project_name}") create_new_file_folder(appName=Project_name) create_git_ignore() create_requirements() create_readme(appName=Project_name) create_license() + def runner(): - if os.path.isdir('src'): + if os.path.isdir("src"): try: - os.system('pip3 install -r requirements.txt') - os.chdir('src') - os.system('python3 main.py') + os.system("pip3 install -r requirements.txt") + os.chdir("src") + os.system("python3 main.py") except: print("ERROR") else: - print('No src folder found') + print("No src folder found") # CLI EXECUTION app = typer.Typer() + @app.command() def create(name: str): start_time = time.time() @@ -86,9 +106,11 @@ def create(name: str): print("\n") print(f"Your application code is in {name}/src/main.py") + @app.command() def run(): runner() -if __name__ == '__main__': - app() \ No newline at end of file + +if __name__ == "__main__": + app() diff --git a/src/writer.py b/src/writer.py index 7954455..b166fc4 100644 --- a/src/writer.py +++ b/src/writer.py @@ -7,8 +7,11 @@ def create_new_file_folder(appName: str): :param appName: Name of Your app that you want to create :return: Project file """ - os.mkdir('src') - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/main.template', 'r') as f, open('src/main.py', 'w') as fw: + os.mkdir("src") + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/main.template", + "r", + ) as f, open("src/main.py", "w") as fw: for line in f: fw.write(line) @@ -16,26 +19,41 @@ def create_new_file_folder(appName: str): def create_git_ignore(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/gitignore.template', 'r') as f, open('.gitignore', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/gitignore.template", + "r", + ) as f, open(".gitignore", "w") as fw: for line in f: fw.write(line) + def create_requirements(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/requirements.template', 'r') as f, open('requirements.txt', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/requirements.template", + "r", + ) as f, open("requirements.txt", "w") as fw: for line in f: fw.write(line) + def create_license(): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/LICENSE.template', 'r') as f, open('LICENSE', 'w') as fw: + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/LICENSE.template", + "r", + ) as f, open("LICENSE", "w") as fw: for line in f: fw.write(line) + def create_readme(appName: str): - with open('/Users/anton/Desktop/Development/Python/fleet-create-app/templates/README.template', 'r') as f, open('README.md', 'w') as fw: - fw.write(f'# {appName}') + with open( + "/Users/anton/Desktop/Development/Python/fleet-create-app/templates/README.template", + "r", + ) as f, open("README.md", "w") as fw: + fw.write(f"# {appName}") fw.write("\n") for line in f: @@ -44,11 +62,10 @@ def create_readme(appName: str): def project_creator(Project_name: str): - os.mkdir(f'{Project_name}') - os.chdir(f'{Project_name}') + os.mkdir(f"{Project_name}") + os.chdir(f"{Project_name}") create_new_file_folder(appName=Project_name) create_git_ignore() create_requirements() create_readme(appName=Project_name) create_license() - diff --git a/tests/test.py b/tests/test.py index b1662d5..2347a49 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1 +1 @@ -# Test TDB \ No newline at end of file +# Test TDB