Skip to content

Commit d0a3f38

Browse files
committed
config nits
1 parent efcea6a commit d0a3f38

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/redfetch/config.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,18 @@ def _annotate_special_resource_comments(toml_text: str) -> str:
237237
if not lines:
238238
return toml_text
239239

240-
pattern = re.compile(r"^\[(DEFAULT|LIVE|TEST|EMU)\.SPECIAL_RESOURCES\.(\d+)\]\s*$")
240+
known_names = set(RESOURCE_NAMES.values())
241+
section_pattern = re.compile(r"^\[(DEFAULT|LIVE|TEST|EMU)\.SPECIAL_RESOURCES\.(\d+)\]\s*$")
241242

242-
new_lines = []
243+
stripped = []
243244
for line in lines:
244-
match = pattern.match(line)
245+
if line.lstrip().startswith("#") and line.lstrip().lstrip("#").strip() in known_names:
246+
continue
247+
stripped.append(line)
248+
249+
new_lines = []
250+
for line in stripped:
251+
match = section_pattern.match(line)
245252
if not match:
246253
new_lines.append(line)
247254
continue
@@ -252,21 +259,17 @@ def _annotate_special_resource_comments(toml_text: str) -> str:
252259
new_lines.append(line)
253260
continue
254261

255-
# Look back in the already-built output for the nearest non-empty line.
256262
idx = len(new_lines) - 1
257263
while idx >= 0 and new_lines[idx].strip() == "":
258264
idx -= 1
259265

260-
# If there's already a comment immediately above, don't add another.
261266
if idx >= 0 and new_lines[idx].lstrip().startswith("#"):
262267
new_lines.append(line)
263268
continue
264269

265-
# Insert the comment and then the header.
266270
new_lines.append(f"# {friendly_name}")
267271
new_lines.append(line)
268272

269-
# Preserve a trailing newline if the original had one.
270273
ending = "\n" if toml_text.endswith("\n") else ""
271274
return "\n".join(new_lines) + ending
272275

src/redfetch/settings.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
DOWNLOAD_FOLDER = "@format {env[REDFETCH_DATA_DIR]}/Downloads"
1010
EQPATH = ""
1111

12-
[DEFAULT.CATEGORY_PATHS]
13-
1412
# ========================================
1513
# XenForo OAuth2
1614
# ========================================

0 commit comments

Comments
 (0)