Skip to content

Commit

Permalink
Added argument to remove __main__.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterEggnog committed Jul 26, 2022
1 parent 5a88822 commit d01e069
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,6 +27,7 @@ def set_python_version():

def main():
set_python_version()
remove_main_if_lib()
print(SUCCESS + "Project successfully initialized" + TERMINATOR)


Expand Down

0 comments on commit d01e069

Please sign in to comment.