MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _parse_gitignore_line

Function _parse_gitignore_line

graphify/detect.py:715–736  ·  view source on GitHub ↗

Parse one raw line from a .graphifyignore file per gitignore spec. - Strip newline chars - Strip inline comments (whitespace + # suffix), but only when # is preceded by whitespace — so path#with#hash.py is preserved - Unescape \\# to literal # - Remove trailing spaces unless e

(raw: str)

Source from the content-addressed store, hash-verified

713
714
715def _parse_gitignore_line(raw: str) -> str:
716 """Parse one raw line from a .graphifyignore file per gitignore spec.
717
718 - Strip newline chars
719 - Strip inline comments (whitespace + # suffix), but only when # is
720 preceded by whitespace — so path#with#hash.py is preserved
721 - Unescape \\# to literal #
722 - Remove trailing spaces unless escaped with backslash
723 - Strip leading whitespace
724 - Return empty string for blank lines and full-line comments
725 """
726 line = raw.rstrip("\n\r")
727 line = line.lstrip()
728 if not line or line.startswith("#"):
729 return ""
730 # Strip inline comments: require whitespace before # (gitignore extension)
731 line = re.sub(r"\s+#+[^\\].*$", "", line)
732 # Unescape \# → literal #
733 line = line.replace("\\#", "#")
734 # Remove unescaped trailing spaces (per gitignore spec)
735 line = re.sub(r"(?<!\\) +$", "", line)
736 return line
737
738
739def _find_vcs_root(start: Path) -> Path | None:

Callers 3

_load_graphifyignoreFunction · 0.85
_load_graphifyincludeFunction · 0.85
detectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected