From 67d6f6f9b821f6f29dca221e4fbaebd47d6c5916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruud=20Schro=C3=ABn?= Date: Sun, 2 Dec 2018 14:07:51 +0100 Subject: [PATCH] Removed unnecessary README files from brewjs and libnx templates --- nxstart/cli.py | 30 ++++++++----- nxstart/filebuilder/brewjs.py | 23 +++++----- nxstart/filebuilder/generic.py | 16 +++---- nxstart/filebuilder/libnx.py | 22 +++++---- nxstart/filebuilder/libt.py | 16 +++---- nxstart/filebuilder/pynx.py | 10 ++--- nxstart/templates/brewjs/assets/README.txt | 1 - nxstart/templates/libnx/data/README.txt | 1 - nxstart/templates/libnx/include/README.txt | 1 - nxstart/templates/pynx/main.py | 4 +- nxstart/tests/helpers.py | 20 ++++----- nxstart/tests/test_cli_brewjs.py | 16 ++++--- nxstart/tests/test_cli_libnx.py | 34 +++++++++----- nxstart/tests/test_cli_libt.py | 34 +++++++++----- nxstart/tests/test_cli_pynx.py | 14 +++--- nxstart/tests/test_utils_files.py | 19 ++++---- nxstart/tests/test_utils_strings.py | 2 +- nxstart/utils/files.py | 6 +-- nxstart/utils/strings.py | 2 +- nxstart/version.py | 2 +- setup.py | 52 +++++++++++----------- 21 files changed, 180 insertions(+), 145 deletions(-) delete mode 100644 nxstart/templates/brewjs/assets/README.txt delete mode 100644 nxstart/templates/libnx/data/README.txt delete mode 100644 nxstart/templates/libnx/include/README.txt diff --git a/nxstart/cli.py b/nxstart/cli.py index baf587e..007f125 100644 --- a/nxstart/cli.py +++ b/nxstart/cli.py @@ -26,22 +26,27 @@ def __init__(self): @click.group() -@click.option('--name', '-n', default=None, help='The name of your project') -@click.option('--author', '-a', default=None, help='The full name of the author') +@click.option("--name", "-n", default=None, help="The name of your project") +@click.option("--author", "-a", default=None, help="The full name of the author") @pass_context def cli(ctx, name, author): click.echo(TITLE_TEXT) click.echo(VERSION_STRING) if not name: - name = click.prompt('Please enter the name of your project', type=str) + name = click.prompt("Please enter the name of your project", type=str) if not author: - author = click.prompt('Please enter your name', type=str) + author = click.prompt("Please enter your name", type=str) ctx.name = name ctx.author = author -@cli.command('libnx', short_help='create a new libnx project (C++)') -@click.option('--clion/--no-clion', default=False, prompt='Are you using CLion?', help='include CMakeLists.txt') +@cli.command("libnx", short_help="create a new libnx project (C++)") +@click.option( + "--clion/--no-clion", + default=False, + prompt="Are you using CLion?", + help="include CMakeLists.txt", +) @pass_context def libnx(ctx, clion): """ @@ -53,8 +58,13 @@ def libnx(ctx, clion): app.libnx(ctx.name, ctx.author, clion, ctx.cwd) -@cli.command('libt', short_help='create a new libtransistor project (C)') -@click.option('--clion/--no-clion', default=False, prompt='Are you using CLion?', help='include CMakeLists.txt') +@cli.command("libt", short_help="create a new libtransistor project (C)") +@click.option( + "--clion/--no-clion", + default=False, + prompt="Are you using CLion?", + help="include CMakeLists.txt", +) @pass_context def libt(ctx, clion): """ @@ -66,7 +76,7 @@ def libt(ctx, clion): app.libt(ctx.name, ctx.author, clion, ctx.cwd) -@cli.command('brewjs', short_help='create a new BrewJS project (Javascript)') +@cli.command("brewjs", short_help="create a new BrewJS project (Javascript)") @pass_context def brewjs(ctx): """ @@ -77,7 +87,7 @@ def brewjs(ctx): app.brewjs(ctx.name, ctx.author, ctx.cwd) -@cli.command('pynx', short_help='create a new PyNX project (Python)') +@cli.command("pynx", short_help="create a new PyNX project (Python)") @pass_context def pynx(ctx): """ diff --git a/nxstart/filebuilder/brewjs.py b/nxstart/filebuilder/brewjs.py index d19dd8c..d4096dd 100644 --- a/nxstart/filebuilder/brewjs.py +++ b/nxstart/filebuilder/brewjs.py @@ -6,7 +6,8 @@ import os from distutils.dir_util import copy_tree -from nxstart.utils.files import get_full_path, replace_in_file +from nxstart.utils.files import (check_and_create_directory, get_full_path, + replace_in_file) def create_brewjs_project(folder_path, name, author): @@ -18,21 +19,23 @@ def create_brewjs_project(folder_path, name, author): :param name: Name of the project :param author: Name of the author """ - template_folder = get_full_path(os.path.join('templates', 'brewjs')) + template_folder = get_full_path(os.path.join("templates", "brewjs")) copy_tree(template_folder, folder_path) - main_js_file = os.path.join(folder_path, 'Source.js') + main_js_file = os.path.join(folder_path, "Source.js") main_js_replacements = { - 'APP_AUTHOR_PLACEHOLDER': author, - 'APP_NAME_PLACEHOLDER': name, - 'DATE_PLACEHOLDER': datetime.datetime.now().strftime("%Y-%m-%d") + "APP_AUTHOR_PLACEHOLDER": author, + "APP_NAME_PLACEHOLDER": name, + "DATE_PLACEHOLDER": datetime.datetime.now().strftime("%Y-%m-%d"), } replace_in_file(main_js_file, main_js_replacements) - package_json_file = os.path.join(folder_path, 'package.json') + package_json_file = os.path.join(folder_path, "package.json") package_json_replacements = { - 'APP_AUTHOR_PLACEHOLDER': author, - 'APP_NAME_PLACEHOLDER': name, - 'DATE_PLACEHOLDER': datetime.datetime.now().strftime("%Y-%m-%d") + "APP_AUTHOR_PLACEHOLDER": author, + "APP_NAME_PLACEHOLDER": name, + "DATE_PLACEHOLDER": datetime.datetime.now().strftime("%Y-%m-%d"), } replace_in_file(package_json_file, package_json_replacements) + + check_and_create_directory(os.path.join(folder_path, "assets")) diff --git a/nxstart/filebuilder/generic.py b/nxstart/filebuilder/generic.py index ba25124..c45d024 100644 --- a/nxstart/filebuilder/generic.py +++ b/nxstart/filebuilder/generic.py @@ -2,6 +2,7 @@ """Includes generic functions such as copying the README.md file.""" +import glob import os from nxstart.utils.files import replace_in_file @@ -15,11 +16,10 @@ def modify_readme_file(folder_path, name, author): :param name: Project name :param author: Project author """ - new_readme_file = os.path.join(folder_path, 'README.md') + new_readme_file = os.path.join(folder_path, "README.md") new_readme_file_replacements = { - 'APP_NAME_PLACEHOLDER': name, - 'APP_AUTHOR_PLACEHOLDER': author - + "APP_NAME_PLACEHOLDER": name, + "APP_AUTHOR_PLACEHOLDER": author, } replace_in_file(new_readme_file, new_readme_file_replacements) @@ -30,7 +30,7 @@ def remove_cmake_lists_file(folder_path): :param folder_path: Path to created folder """ - cmake_lists_file = os.path.join(folder_path, 'CMakeLists.txt') + cmake_lists_file = os.path.join(folder_path, "CMakeLists.txt") os.remove(cmake_lists_file) @@ -41,8 +41,6 @@ def modify_cmake_lists_file(folder_path, folder_name): :param folder_path: Path to created folder :param folder_name: Project folder name """ - cmake_lists_file = os.path.join(folder_path, 'CMakeLists.txt') - cmake_lists_file_replacements = { - 'FOLDER_NAME_PLACEHOLDER': folder_name - } + cmake_lists_file = os.path.join(folder_path, "CMakeLists.txt") + cmake_lists_file_replacements = {"FOLDER_NAME_PLACEHOLDER": folder_name} replace_in_file(cmake_lists_file, cmake_lists_file_replacements) diff --git a/nxstart/filebuilder/libnx.py b/nxstart/filebuilder/libnx.py index e81ef13..e424037 100644 --- a/nxstart/filebuilder/libnx.py +++ b/nxstart/filebuilder/libnx.py @@ -6,7 +6,8 @@ import os from distutils.dir_util import copy_tree -from nxstart.utils.files import get_full_path, replace_in_file +from nxstart.utils.files import (check_and_create_directory, get_full_path, + replace_in_file) def create_libnx_project(folder_path, name, author): @@ -18,20 +19,23 @@ def create_libnx_project(folder_path, name, author): :param name: Name of the project :param author: Name of the author """ - template_folder = get_full_path(os.path.join('templates', 'libnx')) + template_folder = get_full_path(os.path.join("templates", "libnx")) copy_tree(template_folder, folder_path) - main_cpp_file = os.path.join(folder_path, 'source', 'main.cpp') + main_cpp_file = os.path.join(folder_path, "source", "main.cpp") main_cpp_replacements = { - 'APP_AUTHOR_PLACEHOLDER': author, - 'APP_NAME_PLACEHOLDER': name, - 'DATE_PLACEHOLDER': datetime.datetime.now().strftime("%Y-%m-%d") + "APP_AUTHOR_PLACEHOLDER": author, + "APP_NAME_PLACEHOLDER": name, + "DATE_PLACEHOLDER": datetime.datetime.now().strftime("%Y-%m-%d"), } replace_in_file(main_cpp_file, main_cpp_replacements) - makefile = os.path.join(folder_path, 'Makefile') + makefile = os.path.join(folder_path, "Makefile") makefile_replacements = { - 'APP_NAME_PLACEHOLDER': name, - 'APP_AUTHOR_PLACEHOLDER': author + "APP_NAME_PLACEHOLDER": name, + "APP_AUTHOR_PLACEHOLDER": author, } replace_in_file(makefile, makefile_replacements) + + check_and_create_directory(os.path.join(folder_path, "data")) + check_and_create_directory(os.path.join(folder_path, "includes")) diff --git a/nxstart/filebuilder/libt.py b/nxstart/filebuilder/libt.py index e106873..b6320f2 100644 --- a/nxstart/filebuilder/libt.py +++ b/nxstart/filebuilder/libt.py @@ -18,20 +18,20 @@ def create_libt_project(folder_path, name, author): :param name: Name of the project :param author: Name of the author """ - template_folder = get_full_path(os.path.join('templates', 'libt')) + template_folder = get_full_path(os.path.join("templates", "libt")) copy_tree(template_folder, folder_path) - main_c_file = os.path.join(folder_path, 'main.c') + main_c_file = os.path.join(folder_path, "main.c") main_c_replacements = { - 'APP_AUTHOR_PLACEHOLDER': author, - 'APP_NAME_PLACEHOLDER': name, - 'DATE_PLACEHOLDER': datetime.datetime.now().strftime("%Y-%m-%d") + "APP_AUTHOR_PLACEHOLDER": author, + "APP_NAME_PLACEHOLDER": name, + "DATE_PLACEHOLDER": datetime.datetime.now().strftime("%Y-%m-%d"), } replace_in_file(main_c_file, main_c_replacements) - makefile = os.path.join(folder_path, 'Makefile') + makefile = os.path.join(folder_path, "Makefile") makefile_replacements = { - 'APP_NAME_PLACEHOLDER': name, - 'APP_AUTHOR_PLACEHOLDER': author + "APP_NAME_PLACEHOLDER": name, + "APP_AUTHOR_PLACEHOLDER": author, } replace_in_file(makefile, makefile_replacements) diff --git a/nxstart/filebuilder/pynx.py b/nxstart/filebuilder/pynx.py index c5dee52..1a75e71 100644 --- a/nxstart/filebuilder/pynx.py +++ b/nxstart/filebuilder/pynx.py @@ -18,13 +18,13 @@ def create_pynx_project(folder_path, name, author): :param name: Name of the project :param author: Name of the author """ - template_folder = get_full_path(os.path.join('templates', 'pynx')) + template_folder = get_full_path(os.path.join("templates", "pynx")) copy_tree(template_folder, folder_path) - main_cpp_file = os.path.join(folder_path, 'main.py') + main_cpp_file = os.path.join(folder_path, "main.py") main_cpp_replacements = { - 'APP_AUTHOR_PLACEHOLDER': author, - 'APP_NAME_PLACEHOLDER': name, - 'DATE_PLACEHOLDER': datetime.datetime.now().strftime("%Y-%m-%d") + "APP_AUTHOR_PLACEHOLDER": author, + "APP_NAME_PLACEHOLDER": name, + "DATE_PLACEHOLDER": datetime.datetime.now().strftime("%Y-%m-%d"), } replace_in_file(main_cpp_file, main_cpp_replacements) diff --git a/nxstart/templates/brewjs/assets/README.txt b/nxstart/templates/brewjs/assets/README.txt deleted file mode 100644 index 1df7bdd..0000000 --- a/nxstart/templates/brewjs/assets/README.txt +++ /dev/null @@ -1 +0,0 @@ -Assets like images, sounds, etc go in this folder diff --git a/nxstart/templates/libnx/data/README.txt b/nxstart/templates/libnx/data/README.txt deleted file mode 100644 index 1df7bdd..0000000 --- a/nxstart/templates/libnx/data/README.txt +++ /dev/null @@ -1 +0,0 @@ -Assets like images, sounds, etc go in this folder diff --git a/nxstart/templates/libnx/include/README.txt b/nxstart/templates/libnx/include/README.txt deleted file mode 100644 index b755a57..0000000 --- a/nxstart/templates/libnx/include/README.txt +++ /dev/null @@ -1 +0,0 @@ -Header files go in this folder diff --git a/nxstart/templates/pynx/main.py b/nxstart/templates/pynx/main.py index 459942d..9021728 100644 --- a/nxstart/templates/pynx/main.py +++ b/nxstart/templates/pynx/main.py @@ -14,8 +14,8 @@ def main(): """ The main loop """ - print('Hello world!') + print("Hello world!") -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/nxstart/tests/helpers.py b/nxstart/tests/helpers.py index 462ad1e..e26c134 100644 --- a/nxstart/tests/helpers.py +++ b/nxstart/tests/helpers.py @@ -6,17 +6,17 @@ import os # Some constants to be used in tests -APP_NAME = 'Test project' -APP_AUTHOR = 'Ruud Schroën' +APP_NAME = "Test project" +APP_AUTHOR = "Ruud Schroën" DATE_CREATED = datetime.datetime.now().strftime("%Y-%m-%d") -DIRECTORY_NAME = 'test_project' +DIRECTORY_NAME = "test_project" -def directory_exists(): +def directory_exists(folder_name=DIRECTORY_NAME): """ - Check if a folder called DIRECTORY_NAME exists + Check if a folder exists """ - return os.path.isdir(DIRECTORY_NAME) + return os.path.isdir(folder_name) def file_exists(file_path): @@ -35,8 +35,8 @@ def file_contains_strings(file_path, strings): :param file_path: File to check :param strings: List of strings """ - with open(os.path.join(DIRECTORY_NAME, file_path), 'r') as file: - data = file.read().replace('\n', '') + with open(os.path.join(DIRECTORY_NAME, file_path), "r") as file: + data = file.read().replace("\n", "") for s in strings: if s not in data: return False @@ -47,11 +47,11 @@ def readme_has_project_and_author_name(): """ Checks that the README.md contains the project and author name. """ - return file_contains_strings('README.md', [APP_NAME, APP_AUTHOR]) + return file_contains_strings("README.md", [APP_NAME, APP_AUTHOR]) def makefile_has_project_and_author_name(): """ Check that the Makefile contains the project and author name. """ - return file_contains_strings('Makefile', [APP_NAME, APP_AUTHOR]) + return file_contains_strings("Makefile", [APP_NAME, APP_AUTHOR]) diff --git a/nxstart/tests/test_cli_brewjs.py b/nxstart/tests/test_cli_brewjs.py index abbec61..4de460c 100644 --- a/nxstart/tests/test_cli_brewjs.py +++ b/nxstart/tests/test_cli_brewjs.py @@ -2,18 +2,22 @@ """Includes test for the 'brewjs' command""" +import os + from click.testing import CliRunner from nxstart.cli import cli -from nxstart.tests.helpers import directory_exists, file_contains_strings, APP_NAME, APP_AUTHOR, DATE_CREATED +from nxstart.tests.helpers import (APP_AUTHOR, APP_NAME, DATE_CREATED, + DIRECTORY_NAME, directory_exists, + file_contains_strings) def test_brewjs(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'brewjs']) + result = runner.invoke(cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "brewjs"]) assert not result.exception - assert result.output.endswith('Successfully created the BrewJS project!\n') - assert directory_exists() - assert file_contains_strings('Source.js', [APP_NAME, APP_AUTHOR, DATE_CREATED]) - assert file_contains_strings('package.json', [APP_NAME, APP_AUTHOR]) + assert result.output.endswith("Successfully created the BrewJS project!\n") + assert directory_exists(os.path.join(DIRECTORY_NAME, "assets")) + assert file_contains_strings("Source.js", [APP_NAME, APP_AUTHOR, DATE_CREATED]) + assert file_contains_strings("package.json", [APP_NAME, APP_AUTHOR]) diff --git a/nxstart/tests/test_cli_libnx.py b/nxstart/tests/test_cli_libnx.py index dc31e3a..5412225 100644 --- a/nxstart/tests/test_cli_libnx.py +++ b/nxstart/tests/test_cli_libnx.py @@ -7,19 +7,24 @@ from click.testing import CliRunner from nxstart.cli import cli -from nxstart.tests.helpers import directory_exists, readme_has_project_and_author_name, \ - makefile_has_project_and_author_name, file_contains_strings, file_exists, APP_AUTHOR, APP_NAME, \ - DATE_CREATED +from nxstart.tests.helpers import (APP_AUTHOR, APP_NAME, DATE_CREATED, + DIRECTORY_NAME, directory_exists, + file_contains_strings, file_exists, + makefile_has_project_and_author_name, + readme_has_project_and_author_name) def test_libnx_with_clion(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'libnx', '--clion']) + result = runner.invoke( + cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "libnx", "--clion"] + ) assert not result.exception - assert result.output.endswith('Successfully created the libnx project!\n') - assert directory_exists() - assert file_exists('CMakeLists.txt') + assert result.output.endswith("Successfully created the libnx project!\n") + assert directory_exists(os.path.join(DIRECTORY_NAME, "data")) + assert directory_exists(os.path.join(DIRECTORY_NAME, "includes")) + assert file_exists("CMakeLists.txt") assert readme_has_project_and_author_name() assert makefile_has_project_and_author_name() assert main_cpp_has_valid_data() @@ -28,15 +33,20 @@ def test_libnx_with_clion(): def test_libnx_without_clion(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'libnx', '--no-clion']) + result = runner.invoke( + cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "libnx", "--no-clion"] + ) assert not result.exception - assert result.output.endswith('Successfully created the libnx project!\n') - assert directory_exists() - assert not file_exists('CMakeLists.txt') + assert result.output.endswith("Successfully created the libnx project!\n") + assert directory_exists(os.path.join(DIRECTORY_NAME, "data")) + assert directory_exists(os.path.join(DIRECTORY_NAME, "includes")) + assert not file_exists("CMakeLists.txt") assert readme_has_project_and_author_name() assert makefile_has_project_and_author_name() assert main_cpp_has_valid_data() def main_cpp_has_valid_data(): - return file_contains_strings(os.path.join('source', 'main.cpp'), [APP_NAME, APP_AUTHOR, DATE_CREATED]) + return file_contains_strings( + os.path.join("source", "main.cpp"), [APP_NAME, APP_AUTHOR, DATE_CREATED] + ) diff --git a/nxstart/tests/test_cli_libt.py b/nxstart/tests/test_cli_libt.py index 7b182c4..c7841e3 100644 --- a/nxstart/tests/test_cli_libt.py +++ b/nxstart/tests/test_cli_libt.py @@ -5,19 +5,25 @@ from click.testing import CliRunner from nxstart.cli import cli -from nxstart.tests.helpers import directory_exists, readme_has_project_and_author_name, \ - makefile_has_project_and_author_name, file_exists, file_contains_strings, APP_AUTHOR, APP_NAME, \ - DATE_CREATED +from nxstart.tests.helpers import (APP_AUTHOR, APP_NAME, DATE_CREATED, + DIRECTORY_NAME, directory_exists, + file_contains_strings, file_exists, + makefile_has_project_and_author_name, + readme_has_project_and_author_name) def test_libt_with_clion(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'libt', '--clion']) + result = runner.invoke( + cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "libt", "--clion"] + ) assert not result.exception - assert result.output.endswith('Successfully created the libtransistor project!\n') - assert directory_exists() - assert file_exists('CMakeLists.txt') + assert result.output.endswith( + "Successfully created the libtransistor project!\n" + ) + assert directory_exists(DIRECTORY_NAME) + assert file_exists("CMakeLists.txt") assert readme_has_project_and_author_name() assert makefile_has_project_and_author_name() assert main_c_has_valid_data() @@ -26,15 +32,19 @@ def test_libt_with_clion(): def test_libt_without_clion(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'libt', '--no-clion']) + result = runner.invoke( + cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "libt", "--no-clion"] + ) assert not result.exception - assert result.output.endswith('Successfully created the libtransistor project!\n') - assert directory_exists() - assert not file_exists('CMakeLists.txt') + assert result.output.endswith( + "Successfully created the libtransistor project!\n" + ) + assert directory_exists(DIRECTORY_NAME) + assert not file_exists("CMakeLists.txt") assert readme_has_project_and_author_name() assert makefile_has_project_and_author_name() assert main_c_has_valid_data() def main_c_has_valid_data(): - return file_contains_strings('main.c', [APP_NAME, APP_AUTHOR, DATE_CREATED]) + return file_contains_strings("main.c", [APP_NAME, APP_AUTHOR, DATE_CREATED]) diff --git a/nxstart/tests/test_cli_pynx.py b/nxstart/tests/test_cli_pynx.py index c75e352..6e813bd 100644 --- a/nxstart/tests/test_cli_pynx.py +++ b/nxstart/tests/test_cli_pynx.py @@ -5,16 +5,18 @@ from click.testing import CliRunner from nxstart.cli import cli -from nxstart.tests.helpers import readme_has_project_and_author_name, file_contains_strings, \ - directory_exists, APP_NAME, APP_AUTHOR, DATE_CREATED +from nxstart.tests.helpers import (APP_AUTHOR, APP_NAME, DATE_CREATED, + DIRECTORY_NAME, directory_exists, + file_contains_strings, + readme_has_project_and_author_name) def test_pynx(): runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['-n', APP_NAME, '-a', APP_AUTHOR, 'pynx']) + result = runner.invoke(cli, ["-n", APP_NAME, "-a", APP_AUTHOR, "pynx"]) assert not result.exception - assert result.output.endswith('Successfully created the PyNX project!\n') - assert directory_exists() - assert file_contains_strings('main.py', [APP_NAME, APP_AUTHOR, DATE_CREATED]) + assert result.output.endswith("Successfully created the PyNX project!\n") + assert directory_exists(DIRECTORY_NAME) + assert file_contains_strings("main.py", [APP_NAME, APP_AUTHOR, DATE_CREATED]) assert readme_has_project_and_author_name() diff --git a/nxstart/tests/test_utils_files.py b/nxstart/tests/test_utils_files.py index bdaed3b..c19116b 100644 --- a/nxstart/tests/test_utils_files.py +++ b/nxstart/tests/test_utils_files.py @@ -5,12 +5,13 @@ import os from nxstart.tests.helpers import DIRECTORY_NAME, file_contains_strings -from nxstart.utils.files import check_and_create_directory, PROJECT_ROOT, get_full_path, replace_in_file +from nxstart.utils.files import (PROJECT_ROOT, check_and_create_directory, + get_full_path, replace_in_file) def test_get_full_path(): - path = os.path.join(PROJECT_ROOT, 'test.py') - path_two = get_full_path('test.py') + path = os.path.join(PROJECT_ROOT, "test.py") + path_two = get_full_path("test.py") assert path == path_two @@ -22,10 +23,8 @@ def test_check_and_create_directory(tmpdir): def test_replace_in_file(tmpdir): - new_test_file_path = str(tmpdir.join('testfile.txt')) - with open(new_test_file_path, 'w') as f: - f.write('TEXT_PLACEHOLDER') - replace_in_file(new_test_file_path, { - 'TEXT_PLACEHOLDER': 'NEW_TEXT', - }) - assert file_contains_strings(new_test_file_path, ['NEW_TEXT']) + new_test_file_path = str(tmpdir.join("testfile.txt")) + with open(new_test_file_path, "w") as f: + f.write("TEXT_PLACEHOLDER") + replace_in_file(new_test_file_path, {"TEXT_PLACEHOLDER": "NEW_TEXT"}) + assert file_contains_strings(new_test_file_path, ["NEW_TEXT"]) diff --git a/nxstart/tests/test_utils_strings.py b/nxstart/tests/test_utils_strings.py index 3a426be..dc33885 100644 --- a/nxstart/tests/test_utils_strings.py +++ b/nxstart/tests/test_utils_strings.py @@ -4,7 +4,7 @@ import os -from nxstart.tests.helpers import DIRECTORY_NAME, APP_NAME +from nxstart.tests.helpers import APP_NAME, DIRECTORY_NAME from nxstart.utils.strings import generate_folder_name_and_path diff --git a/nxstart/utils/files.py b/nxstart/utils/files.py index 7392c58..e638ba1 100644 --- a/nxstart/utils/files.py +++ b/nxstart/utils/files.py @@ -3,7 +3,7 @@ """Includes functions for working with the filesystem.""" import os -from os.path import join, dirname +from os.path import dirname, join import click @@ -33,7 +33,7 @@ def replace_in_file(file, replacements): for src, target in replacements.items(): line = line.replace(src, target) lines.append(line) - with open(file, 'w') as outfile: + with open(file, "w") as outfile: for line in lines: outfile.write(line) @@ -45,7 +45,7 @@ def check_and_create_directory(folder_path): :param folder_path: Directory to create """ if os.path.exists(folder_path): - click.echo('Directory at %s is not empty.' % folder_path, err=True) + click.echo("Directory at %s is not empty." % folder_path, err=True) raise click.Abort() os.makedirs(folder_path) diff --git a/nxstart/utils/strings.py b/nxstart/utils/strings.py index 6b58849..b8a023a 100644 --- a/nxstart/utils/strings.py +++ b/nxstart/utils/strings.py @@ -15,7 +15,7 @@ # # # # #### # # # # # # """ -VERSION_STRING = 'v%s - by roedesh ' % version +VERSION_STRING = "v%s - by roedesh " % version def generate_folder_name_and_path(name, cwd): diff --git a/nxstart/version.py b/nxstart/version.py index 7b344ec..0b2f79d 100644 --- a/nxstart/version.py +++ b/nxstart/version.py @@ -1 +1 @@ -__version__ = '1.1.2' +__version__ = "1.1.3" diff --git a/setup.py b/setup.py index 25450c9..016be24 100644 --- a/setup.py +++ b/setup.py @@ -6,48 +6,46 @@ # Get the version number version = {} -with open(os.path.join(dir_path, 'nxstart', 'version.py')) as fp: +with open(os.path.join(dir_path, "nxstart", "version.py")) as fp: exec(fp.read(), version) def readme(): - with open('README.rst') as f: + with open("README.rst") as f: return f.read() setup( - name='nxstart', - description='Nintendo Switch homebrew project generator', + name="nxstart", + description="Nintendo Switch homebrew project generator", long_description=readme(), - long_description_content_type='text/markdown', - version=version['__version__'], - url='https://github.com/roedesh/nxstart', - author='Ruud Schroën', - license='MIT', - keywords='nintendo switch libnx nx homebrew project generator', + long_description_content_type="text/markdown", + version=version["__version__"], + url="https://github.com/roedesh/nxstart", + author="Ruud Schroën", + license="MIT", + keywords="nintendo switch libnx nx homebrew project generator", packages=find_packages(), include_package_data=True, - install_requires=[ - 'Click' - ], - entry_points=''' + install_requires=["Click"], + entry_points=""" [console_scripts] nxstart=nxstart.cli:cli - ''', + """, project_urls={ - 'Bug Reports': 'https://github.com/roedesh/nxstart/issues', - 'Source': 'https://github.com/roedesh/nxstart', + "Bug Reports": "https://github.com/roedesh/nxstart/issues", + "Source": "https://github.com/roedesh/nxstart", }, classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Topic :: Software Development :: Code Generators', - 'Topic :: Utilities' + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Topic :: Software Development :: Code Generators", + "Topic :: Utilities", ], )