Ejemplo n.º 1
0
 def setUp(self):
     testset_path = os.path.join(os.path.dirname(__file__),
                                 "testset/01/010001/0001.xml")
     self.rr = xml_lawdata.ReikiXMLReader(testset_path)
     self.rr.open()
     assert self.rr.get_tree(
     ) is not None, "test set path is invalid.\n" + str(testset_path)
Ejemplo n.º 2
0
    def setUp(self):
        testset_path = os.path.join(os.path.dirname(__file__),
                                    "testset/01/010001/0001.xml")
        self.xml_rr = xml_lawdata.ReikiXMLReader(testset_path)
        self.xml_rr.open()
        assert self.xml_rr.get_tree(
        ) is not None, "test set path is invalid.\n" + str(testset_path)

        writer = ml_lawdata.JStatutreeKVS(DB_PATH)
        writer.set_from_reader(self.xml_rr)
        #print("writer: ",list(writer["lawdata"].items()))
        self.rr = ml_lawdata.ReikiKVSReader(code="01/010001/0001", db=writer)
Ejemplo n.º 3
0
 def setUp(self):
     self.levels = [Law, Article, Sentence]
     self.treedict = JStatutreeKVSDict(path=DB_PATH,
                                       levels=self.levels,
                                       create_if_missing=True)
     self.sentence_dicts = {
         level.__name__: JSSentenceKVSDict(kvsdict=self.treedict,
                                           level=level)
         for level in self.levels
     }
     self.rr = xml_lawdata.ReikiXMLReader(
         os.path.join(os.path.dirname(__file__),
                      "testset/01/010001/0001.xml"))
     self.rr.open()
Ejemplo n.º 4
0
 def register_directory(self, basepath, overwrite=False):
     if not overwrite and not self.kvsdicts["lawdata"].is_empty():
         print("skip registering")
         return
     for path in find_all_files(basepath, [".xml"]):
         try:
             rr = xml_lawdata.ReikiXMLReader(path)
             rr.open()
             if rr.is_closed():
                 continue
             self.set_data(rr)
             rr.close()
         except LawError as e:
             pass
             #print(e)
     self.is_empty = False