module documentation
Parse .gitattributes file.
| Class | |
A collection of gitattributes patterns that can match paths. |
| Class | |
A single gitattributes pattern. |
| Function | match |
Get attributes for a path by matching against patterns. |
| Function | parse |
Parse a Git attributes string. |
| Function | parse |
Parse a gitattributes file and return compiled patterns. |
| Function | read |
Read .gitattributes from a directory. |
| Variable | |
Undocumented |
| Function | _parse |
Parse a git attribute into its value. |
| Function | _translate |
Translate a gitattributes pattern to a regular expression. |
def match_path(patterns:
Sequence[ tuple[ Pattern, Mapping[ bytes, AttributeValue]]], path: bytes) -> dict[ bytes, AttributeValue]:
¶
Get attributes for a path by matching against patterns.
| Parameters | |
patterns:Sequence[ | List of (Pattern, attributes) tuples |
path:bytes | Path to match (relative to repository root) |
| Returns | |
dict[ | Dictionary of attributes that apply to this path |
def parse_git_attributes(f:
IO[ bytes]) -> Generator[ tuple[ bytes, Mapping[ bytes, AttributeValue]], None, None]:
¶
Parse a Git attributes string.
>>> from io import BytesIO >>> list(parse_git_attributes(BytesIO(b'''*.tar.* filter=lfs diff=lfs merge=lfs -text ... ... # store signatures in Git ... *.tar.*.asc -filter -diff merge=binary -text ... ... # store .dsc verbatim ... *.dsc -filter !diff merge=binary !text ... '''))) #doctest: +NORMALIZE_WHITESPACE [(b'*.tar.*', {'filter': 'lfs', 'diff': 'lfs', 'merge': 'lfs', 'text': False}), (b'*.tar.*.asc', {'filter': False, 'diff': False, 'merge': 'binary', 'text': False}), (b'*.dsc', {'filter': False, 'diff': None, 'merge': 'binary', 'text': None})]
| Parameters | |
f:IO[ | File-like object to read bytes from |
| Returns | |
Generator[ | List of patterns and corresponding patterns in the order or them being encountered |