Skip to content

Commit c2934e4

Browse files
committed
moved cookie to toml
1 parent 2134644 commit c2934e4

12 files changed

+223
-753
lines changed

.coveragerc

Lines changed: 0 additions & 7 deletions
This file was deleted.

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Makefile for project needs
2+
# Author: Ben Trachtenberg
3+
# Version: 1.0.0
4+
#
5+
6+
.PHONY: all info coverage pytest black
7+
8+
info:
9+
@echo "make options"
10+
@echo " black To format code with black"
11+
@echo " coverage To run coverage and display ASCII and output to htmlcov"
12+
@echo " pytest To run pytest with verbose option"
13+
14+
all: coverage black pylint
15+
16+
coverage:
17+
@pytest --cov --cov-report=html -vvv
18+
19+
pytest:
20+
@pytest --cov -vvv
21+
22+
pylint:
23+
@pylint hooks/
24+
25+
black:
26+
@black hooks/
27+
@black tests/

hooks/post_gen_project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
post generation hooks for cookiecutter to remove unneeded files
33
"""
4+
45
from typing import List
56
import os
67
import shutil
@@ -19,6 +20,7 @@
1920
'{% if cookiecutter.container_runtime == "docker" %}containers/Containerfile{% endif %}',
2021
]
2122

23+
2224
def remove_paths(paths_to_remove: List[str]) -> None:
2325
"""Remove files and directories
2426
@@ -35,7 +37,7 @@ def remove_paths(paths_to_remove: List[str]) -> None:
3537
shutil.rmtree(path)
3638

3739

38-
if __name__ == '__main__':
40+
if __name__ == "__main__":
3941
remove_paths(REMOVE_PATHS_NO_WEBPAGES)
4042
remove_paths(REMOVE_PATHS_PODMAN)
4143
remove_paths(REMOVE_PATHS_DOCKER)

hooks/pre_gen_project.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
pre generation hooks for cookiecutter to validate data
33
"""
4+
45
import re
56
import sys
67

@@ -16,7 +17,7 @@ def validate_no_spaces(arg_name: str, human_readable_name: str) -> None:
1617
:rtype: None
1718
:return: Nothing it exits if the arg_name is invalid
1819
"""
19-
arg_regex = r'^\S+$'
20+
arg_regex = r"^\S+$"
2021
if not re.match(arg_regex, arg_name):
2122
print(f'ERROR: "{arg_name}" is not a valid {human_readable_name} no spaces allowed!')
2223
sys.exit(1)
@@ -33,7 +34,7 @@ def validate_no_spaces_begin_or_end(arg_name: str, human_readable_name: str) ->
3334
:rtype: None
3435
:return: Nothing it exits if the arg_name is invalid
3536
"""
36-
arg_regex = r'^\S.*\S$'
37+
arg_regex = r"^\S.*\S$"
3738
if not re.match(arg_regex, arg_name):
3839
print(f'ERROR: "{arg_name}" is not a valid {human_readable_name} no spaces allowed at the beginning or ending!')
3940
sys.exit(1)
@@ -50,7 +51,7 @@ def validate_semantic_version(arg_name: str, human_readable_name: str) -> None:
5051
:rtype: None
5152
:return: Nothing it exits if the arg_name is invalid
5253
"""
53-
arg_regex = r'^\d+\.\d+\.\d+$'
54+
arg_regex = r"^\d+\.\d+\.\d+$"
5455
if not re.match(arg_regex, arg_name):
5556
print(f'ERROR: "{arg_name}" is not a valid {human_readable_name} should be semantic X.X.X!')
5657
sys.exit(1)
@@ -67,7 +68,7 @@ def validate_https_url(arg_name: str, human_readable_name: str) -> None:
6768
:rtype: None
6869
:return: Nothing it exits if the arg_name is invalid
6970
"""
70-
arg_regex = r'^https://\S+$'
71+
arg_regex = r"^https://\S+$"
7172
if not re.match(arg_regex, arg_name):
7273
print(f'ERROR: "{arg_name}" is not a valid {human_readable_name} should start with https://!')
7374
sys.exit(1)
@@ -84,22 +85,27 @@ def validate_numbers_letters_hyphens(arg_name: str, human_readable_name: str) ->
8485
:rtype: None
8586
:return: Nothing it exits if the arg_name is invalid
8687
"""
87-
arg_regex = r'^([A-Z]|[a-z]|[0-9]|-{1})+$'
88+
arg_regex = r"^([A-Z]|[a-z]|[0-9]|-{1})+$"
8889
if not re.match(arg_regex, arg_name):
8990
print(f'ERROR: "{arg_name}" is not a valid {human_readable_name} should be numbers, letters and hyphens!')
9091
sys.exit(1)
9192

9293

93-
if __name__ == '__main__':
94-
validate_no_spaces_begin_or_end(arg_name='{{ cookiecutter.full_name }}',
95-
human_readable_name='full_name') # pragma: no cover
96-
validate_no_spaces(arg_name='{{ cookiecutter.email }}', human_readable_name='email') # pragma: no cover
97-
validate_no_spaces(arg_name='{{ cookiecutter.git_username }}',
98-
human_readable_name='git_username') # pragma: no cover
99-
validate_numbers_letters_hyphens(arg_name='{{ cookiecutter.git_repo_name }}',
100-
human_readable_name='git_repo_name') # pragma: no cover
101-
validate_https_url(arg_name='{{ cookiecutter.git_url }}', human_readable_name='git_url') # pragma: no cover
102-
validate_no_spaces_begin_or_end(arg_name='{{ cookiecutter.app_description }}',
103-
human_readable_name='app_description') # pragma: no cover
104-
validate_semantic_version(arg_name='{{ cookiecutter.app_version }}',
105-
human_readable_name='app_version') # pragma: no cover
94+
if __name__ == "__main__":
95+
validate_no_spaces_begin_or_end(
96+
arg_name="{{ cookiecutter.full_name }}", human_readable_name="full_name"
97+
) # pragma: no cover
98+
validate_no_spaces(arg_name="{{ cookiecutter.email }}", human_readable_name="email") # pragma: no cover
99+
validate_no_spaces(
100+
arg_name="{{ cookiecutter.git_username }}", human_readable_name="git_username"
101+
) # pragma: no cover
102+
validate_numbers_letters_hyphens(
103+
arg_name="{{ cookiecutter.git_repo_name }}", human_readable_name="git_repo_name"
104+
) # pragma: no cover
105+
validate_https_url(arg_name="{{ cookiecutter.git_url }}", human_readable_name="git_url") # pragma: no cover
106+
validate_no_spaces_begin_or_end(
107+
arg_name="{{ cookiecutter.app_description }}", human_readable_name="app_description"
108+
) # pragma: no cover
109+
validate_semantic_version(
110+
arg_name="{{ cookiecutter.app_version }}", human_readable_name="app_version"
111+
) # pragma: no cover

make.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@ECHO OFF
2+
REM Makefile for project needs
3+
REM Author: Ben Trachtenberg
4+
REM Version: 1.0.0
5+
REM
6+
7+
IF "%1" == "all" (
8+
pytest --cov --cov-report=html -vvv
9+
black hooks\
10+
black tests\
11+
pylint hooks\
12+
GOTO END
13+
)
14+
15+
IF "%1" == "coverage" (
16+
pytest --cov --cov-report=html -vvv
17+
GOTO END
18+
)
19+
20+
IF "%1" == "pylint" (
21+
pylint hooks\
22+
GOTO END
23+
)
24+
25+
IF "%1" == "pytest" (
26+
pytest --cov -vvv
27+
GOTO END
28+
)
29+
30+
IF "%1" == "black" (
31+
black hooks\
32+
black tests\
33+
GOTO END
34+
)
35+
36+
@ECHO make options
37+
@ECHO coverage To run coverage and display ASCII and output to htmlcov
38+
@ECHO black To format the code with black
39+
@ECHO pylint To run pylint
40+
@ECHO pytest To run pytest with verbose option
41+
42+
:END

0 commit comments

Comments
 (0)