Skip to content

Commit 21dc8dc

Browse files
committed
Read inputs for prefs
1 parent 666e360 commit 21dc8dc

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ APPLICATION_NAME=pyflask-microservice
55

66
APP_DIR=src
77
TEST_DIR=test
8+
SCRIPTS_DIR=scripts
89
HOME_DIR_PY_FILES=*.py
910

1011
# echo _FormatCode_ guide:
@@ -97,21 +98,21 @@ upgrade: #: upgrade requirements to latest versions
9798
format: #: Format and fix python code with black, isort, autoflake
9899
@echo "\n$(BOLD_BLUE)Blackifying$(RESET_STYLES) 🍳"
99100
black --version
100-
black $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
101+
black $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) $(SCRIPTS_DIR)
101102
@echo "\n$(BOLD_CYAN)ISorting$(RESET_STYLES) 〽️️"
102-
isort $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
103+
isort $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) $(SCRIPTS_DIR)
103104
@echo "\n$(BOLD_CYAN)Flaking$(RESET_STYLES) ❄️"
104105
flake8 --version
105-
autoflake --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --ignore-init-module-imports -i -r $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
106+
autoflake --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --ignore-init-module-imports -i -r $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) $(SCRIPTS_DIR)
106107

107108

108109
lint: #: Run static analysis with flake8, radon, mypy and bandit
109110
@echo "\n$(BOLD_CYAN)Linting with flake8$(RESET_STYLES) ❄️"
110111
flake8 --version
111-
flake8 $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
112+
flake8 $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) $(SCRIPTS_DIR)
112113
@echo "\n$(BOLD_CYAN)Checking cyclomatic complexity with radon$(RESET_STYLES) 💫️"
113114
radon --version
114-
radon cc $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) --total-average -nc
115+
radon cc $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) $(SCRIPTS_DIR) --total-average -nc
115116
@echo "\n$(BOLD_CYAN)Static typing with mypy$(RESET_STYLES) ⌨️"
116117
mypy --version
117118
mypy $(APP_DIR) $(HOME_DIR_PY_FILES)

pyflask-preferences.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
docker_maintainer_details: User <[email protected]>
2-
is_personalized: false
2+
is_personalized: true
33
python_base_version_major: 3
44
python_base_version_minor: 8
55
python_env_manager: venv

scripts/dev/personalize.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44

5+
import inquirer
56
import yaml
67

78
if __name__ == "__main__":
@@ -20,7 +21,32 @@
2021
# The FullLoader parameter handles the conversion from YAML
2122
# scalar values to Python the dictionary format
2223
pyflask_pref_dict = yaml.load(file, Loader=yaml.FullLoader)
23-
print(pyflask_pref_dict)
24+
25+
new_service_name = input(f"Enter service name: (current_name = {pyflask_pref_dict['service_name']}) :: ")
26+
pyflask_pref_dict["service_name"] = new_service_name if new_service_name != "" else pyflask_pref_dict["service_name"]
27+
28+
new_python_env_name = input(f"Enter python environment name: (current_name {pyflask_pref_dict['python_env_name']}) :: ")
29+
pyflask_pref_dict["python_env_name"] = (
30+
new_python_env_name if new_python_env_name != "" else pyflask_pref_dict["python_env_name"]
31+
)
32+
33+
questions = [inquirer.List("python_version", message="Use python version :: ", choices=["3.7", "3.8"])]
34+
answers = inquirer.prompt(questions)
35+
if answers["python_version"] == "3.8":
36+
pyflask_pref_dict["python_base_version_minor"] = 8
37+
elif answers["python_version"] == "3.7":
38+
pyflask_pref_dict["python_base_version_minor"] = 7
39+
40+
questions = [inquirer.List("python_env_manager", message="Use python env manager :: ", choices=["conda", "venv"])]
41+
answers = inquirer.prompt(questions)
42+
pyflask_pref_dict["python_env_manager"] = answers["python_env_manager"]
43+
44+
new_docker_maintainer_username = input("Enter docker maintainer username :: ")
45+
new_docker_maintainer_email = input("Enter docker maintainer email :: ")
46+
pyflask_pref_dict["docker_maintainer_details"] = f"{new_docker_maintainer_username} <{new_docker_maintainer_email}>"
47+
48+
pyflask_pref_dict["is_personalized"] = True
49+
2450
with open(r"./pyflask-preferences.yaml", "w") as file:
2551
documents = yaml.dump(pyflask_pref_dict, file)
2652

scripts/dev/service_init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function main() {
5151
echo "$style_bold_blue""Starting project personalization . . .""$style_reset"
5252
rm -rf .github
5353
pip3 install pyyaml
54+
pip3 install inquirer
5455
python3 scripts/dev/personalize.py "$pyflask_pref_python_env_name"
5556
printf "\n"
5657
fi

0 commit comments

Comments
 (0)