Skip to content

Commit c40fcd4

Browse files
committed
Change parameter in initialize_project_title() and initialize_project_nb()
1 parent 50629b6 commit c40fcd4

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/main/main.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@ def initialize_project_config(env_vars: dict[str, str | int]) -> int:
137137
return 1
138138

139139

140-
def initialize_project_title(env_vars: dict[str, str | int]) -> int:
140+
def initialize_project_title(proj_title: str) -> int:
141141
"""
142142
Updates project title in README and solution template files.
143143
144144
Args:
145-
env_vars: Dictionary containing project configuration values
146-
Required key: 'proj_title'
145+
proj_title (str): Name of project title
147146
148147
Returns:
149148
int: 1 if title update successful
@@ -152,7 +151,7 @@ def initialize_project_title(env_vars: dict[str, str | int]) -> int:
152151
with open('README.md', 'r+', encoding='utf-8') as file:
153152
lines_readme_title = file.readlines()
154153

155-
lines_readme_title[0] = f'# {env_vars['proj_title']}\n'
154+
lines_readme_title[0] = f'# {proj_title}\n'
156155

157156
file.seek(0)
158157
file.writelines(lines_readme_title)
@@ -162,7 +161,7 @@ def initialize_project_title(env_vars: dict[str, str | int]) -> int:
162161
with open('src/main/templates/solution.txt', 'r+', encoding='utf-8') as file:
163162
lines_template_title = file.readlines()
164163

165-
lines_template_title[0] = f'# {env_vars["proj_title"]} \\#{{{{ seq_full }}}}\n'
164+
lines_template_title[0] = f'# {proj_title} \\#{{{{ seq_full }}}}\n'
166165

167166
file.seek(0)
168167
file.writelines(lines_template_title)
@@ -172,20 +171,19 @@ def initialize_project_title(env_vars: dict[str, str | int]) -> int:
172171
return 1
173172

174173

175-
def initialize_project_nb(env_vars: dict[str, str | int]) -> int:
174+
def initialize_project_nb(nb_name: str) -> int:
176175
"""
177176
Sets up NB in README and solution template files.
178177
179178
Args:
180-
env_vars: Dictionary containing project configuration values
181-
Required key: 'nb_name' for extra column header
179+
nb_name (str): Name for extra column header
182180
183181
Returns:
184182
int: 1 if nb initialization successful
185183
"""
186184
index_header = {
187-
'labels': f'| Day | Title | Solution | Site | Difficulty | {env_vars["nb_name"]} |',
188-
'sep': f'| ----- | ------- | ---------- | ------ | ------------ | { "-" * (len(env_vars["nb_name"]) + 2) } |'
185+
'labels': f'| Day | Title | Solution | Site | Difficulty | {nb_name} |',
186+
'sep': f'| ----- | ------- | ---------- | ------ | ------------ | { "-" * (len(nb_name) + 2) } |'
189187
}
190188

191189
start_line_readme = None
@@ -219,14 +217,14 @@ def initialize_project_nb(env_vars: dict[str, str | int]) -> int:
219217
with open(f'{TEMPLATES_DIR}/solution.txt', 'r+', encoding='utf-8') as file:
220218
lines_template = file.readlines()
221219

222-
lines_template[29] = f'## {env_vars["nb_name"]}\n'
220+
lines_template[29] = f'## {nb_name}\n'
223221
lines_template[32] = '\n'
224222

225223
file.seek(0)
226224
file.writelines(lines_template)
227225
file.truncate()
228226

229-
print(f'Extra column selected: {env_vars["nb_name"]}')
227+
print(f'Extra column selected: {nb_name}')
230228

231229

232230
return 1
@@ -296,11 +294,11 @@ def initialize_project(handler: PackageHandler, today: datetime) -> int:
296294

297295
# HANDLE PROJECT TITLE
298296
if env_vars['proj_title'] != '[ ] Everyday':
299-
initialize_project_title(env_vars)
297+
initialize_project_title(env_vars['proj_title'])
300298

301299
# HANDLE EXTRA COLUMN (aka NB)
302300
if env_vars['nb'] == 1:
303-
initialize_project_nb(env_vars)
301+
initialize_project_nb(env_vars['nb_name'])
304302

305303
# HANDLE .ENV
306304
initialize_project_env()

0 commit comments

Comments
 (0)