MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / process

Method process

tensorflow/tools/docs/py_guide_parser.py:45–83  ·  view source on GitHub ↗

Read and process the file at `full_path`.

(self, full_path)

Source from the content-addressed store, hash-verified

43 self._lines = None
44
45 def process(self, full_path):
46 """Read and process the file at `full_path`."""
47 with open(full_path, 'rb') as f:
48 md_string = f.read().decode('utf-8')
49 self._lines = md_string.split('\n')
50 seen = set()
51
52 in_blockquote = False
53 for i, line in enumerate(self._lines):
54 if '```' in line:
55 in_blockquote = not in_blockquote
56
57 if not in_blockquote and line.startswith('# '):
58 self.process_title(i, line[2:])
59 elif not in_blockquote and line.startswith('## '):
60 section_title = line.strip()[3:]
61 existing_tag = re.search(' {([^}]+)} *$', line)
62 if existing_tag:
63 tag = existing_tag.group(1)
64 else:
65 tag = re.sub('[^a-zA-Z0-9]+', '_', section_title)
66 if tag in seen:
67 suffix = 0
68 while True:
69 candidate = '%s_%d' % (tag, suffix)
70 if candidate not in seen:
71 tag = candidate
72 break
73 seen.add(tag)
74 self.process_section(i, section_title, tag)
75
76 elif in_blockquote:
77 self.process_in_blockquote(i, line)
78 else:
79 self.process_line(i, line)
80
81 ret = '\n'.join(self._lines)
82 self._lines = None
83 return ret
84
85 def replace_line(self, line_number, line):
86 """Replace the contents of line numbered `line_number` with `line`."""

Callers

nothing calls this directly

Calls 12

process_titleMethod · 0.95
process_sectionMethod · 0.95
process_in_blockquoteMethod · 0.95
process_lineMethod · 0.95
stripMethod · 0.80
decodeMethod · 0.45
readMethod · 0.45
splitMethod · 0.45
groupMethod · 0.45
subMethod · 0.45
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected