MCPcopy
hub / github.com/LawRefBook/Laws / write_law

Method write_law

scripts/request.py:138–152  ·  view source on GitHub ↗
(self, path: Path, data: List[str])

Source from the content-addressed store, hash-verified

136 f.write(data if isinstance(data, str) else str(data))
137
138 def write_law(self, path: Path, data: List[str]):
139 out_path = self.base_path / "out"
140 if not out_path.exists():
141 out_path.mkdir()
142 full_path = out_path / path
143 folder_path = full_path.parents[0]
144 if not folder_path.exists():
145 folder_path.mkdir()
146 with open(full_path, "w") as f:
147 result = "\n\n".join(data)
148 result = result.replace("<!-- TABLE -->\n", "<!-- TABLE -->")
149 result = result.replace("\n<!-- TABLE END -->", "<!-- TABLE END -->")
150 result = result.replace("|\n\n|", "|\n|")
151 result = re.sub("\n{2,}", "\n\n", result)
152 f.write(result)
153
154
155class RequestManager(object):

Callers 2

parse_lawMethod · 0.80
parse_fileMethod · 0.80

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected