diff --git a/cookiecutter.json b/cookiecutter.json index 4ea59c0..8b9867d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,4 +1,5 @@ { "project_name": "Best Practices", - "repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}" + "repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}", + "binary":"y" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index afcc8ba..3f60bb7 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -13,6 +13,12 @@ def set_python_version(): with open(file_name, "w") as f: f.write(contents) +def remove_main_if_lib(): + is_lib = '{{ cookiecutter.binary }}' + main_file_path = os.path.join('{{ cookiecutter.repo_name }}', '__main__.py') + if not (is_lib == "y" or is_lib == "Y"): + os.remove(main_file_path) + print(main_file_path) SUCCESS = "\x1b[1;32m" INFO = "\x1b[1;33m" @@ -21,6 +27,7 @@ def set_python_version(): def main(): set_python_version() + remove_main_if_lib() print(SUCCESS + "Project successfully initialized" + TERMINATOR)