Skip to content

Commit 71ea15f

Browse files
committed
Fix handling of activated sixth column when updating README
1 parent 6a24dd0 commit 71ea15f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/main/helpers/helpers.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from jinja2 import Template
1010

1111
# Local
12-
from src.main.config import NB
1312
from src.main.config import TEMPLATES_DIR
1413

1514

@@ -64,7 +63,7 @@ def get_files_created(data: Dict[str, Any]) -> int:
6463
return 1
6564

6665

67-
def get_target_line_dict(line: str) -> Dict[str, str]:
66+
def get_target_line_dict(nb_loc, line: str) -> Dict[str, str]:
6867
"""
6968
Parse a table line into a dictionary based on notebook configuration.
7069
@@ -87,11 +86,11 @@ def get_target_line_dict(line: str) -> Dict[str, str]:
8786
"nb": "",
8887
}
8988

90-
if NB == 0:
89+
if nb_loc == 0:
9190

9291
keys = list(data.keys())[:-1] # Exclude 'nb'
9392

94-
elif NB == 1:
93+
elif nb_loc == 1:
9594

9695
keys = list(data.keys())
9796

@@ -115,7 +114,7 @@ def get_target_line_dict(line: str) -> Dict[str, str]:
115114
return results
116115

117116

118-
def get_target_line_updated(data: Dict[str, str], widths: Dict[str, int]) -> str:
117+
def get_target_line_updated(nb_loc, data: Dict[str, str], widths: Dict[str, int]) -> str:
119118
"""
120119
Format a table line with proper padding based on column widths.
121120
@@ -132,7 +131,7 @@ def get_target_line_updated(data: Dict[str, str], widths: Dict[str, int]) -> str
132131

133132
target_line = "|"
134133

135-
if NB == 0:
134+
if nb_loc == 0:
136135

137136
for key, value in data.items():
138137

@@ -148,7 +147,7 @@ def get_target_line_updated(data: Dict[str, str], widths: Dict[str, int]) -> str
148147

149148
target_line += f" {value_str}{padding} |"
150149

151-
elif NB == 1:
150+
elif nb_loc == 1:
152151

153152
for key, value in data.items():
154153

src/main/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ def implement_runs(handler: PackageHandler) -> int:
390390
if handler.get_value("entry_data", "nb"):
391391
handler.update_value("entry_data", "nb", "")
392392

393-
new_entry = get_target_line_updated(handler.get_dictionary("entry_data"),
393+
new_entry = get_target_line_updated(handler.get_value("config_base", "nb_loc"),
394+
handler.get_dictionary("entry_data"),
394395
handler.get_dictionary("config_cols_widths"))
395396

396397

@@ -423,10 +424,12 @@ def implement_runs(handler: PackageHandler) -> int:
423424
for i in range(start_line + 1, end_line):
424425

425426
# Convert target line (str) to data (dict)
426-
target_line_data = get_target_line_dict(lines[i])
427+
target_line_data = get_target_line_dict(handler.get_value("config_base", "nb_loc"),
428+
lines[i])
427429

428430
# Update target line
429-
line_updated = get_target_line_updated(target_line_data,
431+
line_updated = get_target_line_updated(handler.get_value("config_base", "nb_loc"),
432+
target_line_data,
430433
handler.get_dictionary("config_cols_widths"))
431434

432435
# Replace the original line with the updated one

0 commit comments

Comments
 (0)