MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / _file_line

Function _file_line

tests/test_release.py:20–37  ·  view source on GitHub ↗

Returns : for location of regex match. path: filename. text: Contents of . re_match: A re.Match. offset: Added to line number of start of . Default offset=2 is because callers usually grep for leading n

(path, text, re_match, offset=+2)

Source from the content-addressed store, hash-verified

18
19
20def _file_line(path, text, re_match, offset=+2):
21 '''
22 Returns <file>:<line> for location of regex match.
23
24 path:
25 filename.
26 text:
27 Contents of <filename>.
28 re_match:
29 A re.Match.
30 offset:
31 Added to line number of start of <re_match>. Default offset=2 is
32 because callers usually grep for leading newline, and line numbers are
33 generally 1-based.
34 ''&#x27;
35 text_before = text[:re_match.start()]
36 line = text_before.count('\n') + offset
37 return f'{path}:{line}'
38
39
40def test_release_versions():

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…