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

Method parse_law

scripts/request.py:551–578  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

549 return False
550
551 def parse_law(self, item):
552 detail = self.request.get_law_detail(item["id"])
553 result = detail["result"]
554 title = result['title']
555 files = self.__reorder_files(result["body"])
556 logger.debug(f"parsing {title}")
557 if len(files) == 0:
558 return
559
560 target_file = files[0]
561 parser: Parser = find(
562 lambda x: x == target_file["type"],
563 self.parser
564 )
565
566 ret = parser.parse(result, target_file)
567 if not ret:
568 logger.error(f"parsing {title} error")
569 return
570 _, desc, content = ret
571
572 filedata = self.content_parser.parse(result, title, desc, content)
573 if not filedata:
574 return
575
576 output_path = self.__get_law_output_path(title, item["publish"])
577 logger.debug(f"parsing {title} success")
578 self.cache.write_law(output_path, filedata)
579
580 def parse_file(self, file_path, publish_at=None):
581 result = {}

Callers 1

runMethod · 0.95

Calls 6

__reorder_filesMethod · 0.95
__get_law_output_pathMethod · 0.95
findFunction · 0.85
get_law_detailMethod · 0.80
write_lawMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected