comment cleanup

This commit is contained in:
Miguel Jacq 2025-11-27 21:37:29 +11:00
parent bd3f9bf8d2
commit 4f9d1a0442
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
3 changed files with 4 additions and 6 deletions

View file

@ -72,8 +72,8 @@ class IniHandler(BaseHandler):
def _generate_ini_template_from_text(self, role_prefix: str, text: str) -> str: def _generate_ini_template_from_text(self, role_prefix: str, text: str) -> str:
""" """
Generate a Jinja2 template for an INI/php.ini-style file, preserving Generate a Jinja2 template for an INI-style file, preserving comments,
comments, blank lines, and section headers by patching values in-place. blank lines, and section headers by patching values in-place.
""" """
lines = text.splitlines(keepends=True) lines = text.splitlines(keepends=True)
current_section: str | None = None current_section: str | None = None

View file

@ -23,7 +23,7 @@ class JsonHandler(DictLikeHandler):
) -> str: ) -> str:
if not isinstance(parsed, (dict, list)): if not isinstance(parsed, (dict, list)):
raise TypeError("JSON parser result must be a dict or list") raise TypeError("JSON parser result must be a dict or list")
# As before: ignore original_text and rebuild structurally # Rebuild structurally
return self._generate_json_template(role_prefix, parsed) return self._generate_json_template(role_prefix, parsed)
def _generate_json_template(self, role_prefix: str, data: Any) -> str: def _generate_json_template(self, role_prefix: str, data: Any) -> str:

View file

@ -9,7 +9,7 @@ from . import DictLikeHandler
class YamlHandler(DictLikeHandler): class YamlHandler(DictLikeHandler):
fmt = "yaml" fmt = "yaml"
flatten_lists = True # you flatten YAML lists flatten_lists = True
def parse(self, path: Path) -> Any: def parse(self, path: Path) -> Any:
text = path.read_text(encoding="utf-8") text = path.read_text(encoding="utf-8")
@ -97,8 +97,6 @@ class YamlHandler(DictLikeHandler):
out_lines.append(raw_line) out_lines.append(raw_line)
continue continue
# We have an inline scalar value on this same line.
# Separate value from inline comment # Separate value from inline comment
value_part, comment_part = self._split_inline_comment( value_part, comment_part = self._split_inline_comment(
rest_stripped, {"#"} rest_stripped, {"#"}