def addWordStemFile(self, wordStem): # check if the "C1/[.../]CX_n.xml" file exists... wsfTmp = self.wordStemFileSearch(wordStem) if wsfTmp is None: # if not check and build the root as well.. rTmp = self.addRoot(wordStem.root()) # now build the WordStem File.. # first the required data.. #lc_ = extractLC(wordStem) lcv_ = extractLCV(wordStem) lcn_ = extractLCN(wordStem) # get the "C1/[.../]CX_n.xml" file name ... cnFStr_ = genInternalFilename(wordStem.root(),"xml", lcv_) # get the escaped "C1/[.../]CX" root name ... eStr_ = escape(genCurrentRootName(wordStem.root()), True) # and now the file itself .. wsfTmp = self.createInteralNFile(cnFStr_, eStr_, lcn_) # now check in the "CX.xml" root [ index ] file for any # sub-nodes with the href.. chTmp = self.__cxSubNodeSearch(rTmp, eStr_, lcn_, cnFStr_) if not (len(chTmp) > 0): # if it's not there, build it! sTmp = self.__create_child_node(rTmp, eStr_, lcn_, cnFStr_) return wsfTmp
def addRoot(self, root): # get the "C1/[.../]CX.xml" file name... ext_ = self.getInternalFileExt() cxFStr_ = genInternalFilename(root,ext_) # get the escaped "C1/[.../]CX" root name ... eStr_ = escape(genCurrentRootName(root),True) rTmp = self.rootSearch(root) r2Tmp = self.__searchInternalStructure(root) if rTmp is None: rTmp = self.createInteralFile(cxFStr_, eStr_) if r2Tmp is None: self.__addInternalStructure(root) return rTmp
def search(self, root_): ext_ = self.parent().getInternalFileExt() srTmp = genCurrentRootName(root) href_ = genInternalFilename(root_, ext_) rTmp = None for i in self.node(): if i.tag == "Root" and i.get("Value") == srTmp \ and i.get("href") == href_: rTmp = i #rTmp = XMLIndexSubNode( self.parent(), False, i, # dict() ) break return rTmp
def __addInternalStructure(self, root): """ # + Root # | -- Value # | -- href """ rTmp = self.__searchInternalStructure(root) if rTmp is not None: zTmp = self.__cache[b"index.xml"] val_ = genCurrentRootName(root) href_ = genInternalFilename(root, "xml") attrib = { "Value": val_, "href": href_ } rTmp = etree.SubElement(zTmp, "Root", attrib)
def add(self, root_): rTmp = self.search(root_) if rTmp is not None: val_ = genCurrentRootName(root_) ext_ = self.parent().getInternalFileExt() href_ = genInternalFilename(root_, ext_) attrib = { "Value": val_, "href": href_ #, #"XML_Parent_": self.node().node() } rTmp = etree.SubElement(self.node().node(), "Root", attrib) #rTmp = XMLIndexSubNode( self.parent(), True, i, # attrib ) return rTmp