def __handle_blockquote__(self, xmlnode, dstree, dsnode): # Ignore inner value, text data is not allowed valueTail = xmlnode.tail # Encounter paragraph data assumed to be without a pre-inserted p entry if valueTail != None and len(valueTail.strip()) > 0: dsnodeParent = dsnode if util.getLevel(dsnodeParent) != util.levelAbove(DocumentStructure.PARAGRAPH): dsnodeParent = util.getparent(dstree, dsnode) self.peudodsnode = dstree.addNode(dsnodeParent, DocumentStructure.PARAGRAPH, value = valueTail) self.peudodsnodereplace = dsnode return dsnode
def handle(self, dstree, dsnode): value = DocumentStructure.getValue(dsnode) if len(value) != 0: #value = self.dot.sub('. ', value) value = self.multispaces.sub(' ', value) value = self.spacepunct1.sub(',', value) value = self.spacepunct2.sub('.', value) value = value.strip() DocumentStructure.setValue(dsnode, value) if util.getLevel(dsnode) == DocumentStructure.PARAGRAPH: self.__handleParagraph__(dstree, dsnode, value.strip())
def __handle_p__(self, xmlnode, dstree, dsnode): # End a pseudo-p trigger if self.peudoTrigger == True: self.peudoTrigger = False dsnode = self.peudodsnodereplace self.peudodsnodereplace = None self.peudodsnode = None valueText = xmlnode.text valueTail = xmlnode.tail if valueText != None: valueText = valueText.strip() if valueTail != None: valueTail = valueTail.strip() # Encounter a p tag with a pre-inserted p entry if self.preInsertedParagraph == True: dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH) self.abstractHandler.handleReplace(dstree, dsnode, valueText) # Encounter a p tag without a pre-inserted p entry else: dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH) if self.preInsertedParagraph != True: dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH) dsnode = util.getparent(dstree, dsnode) dsnode = dstree.addNode(dsnode, level = DocumentStructure.PARAGRAPH, value = valueText) else: self.abstractHandler.handleReplace(dstree, dsnode, valueText) self.preInsertedParagraph = False # Encounter a p tag without a pre-inserted p entry if valueTail != None and len(valueTail.strip()) > 0: dsnodeParent = dsnode if util.getLevel(dsnodeParent) != util.levelAbove(DocumentStructure.PARAGRAPH): dsnodeParent = util.getparent(dstree, dsnode) self.peudodsnode = dstree.addNode(dsnodeParent, DocumentStructure.PARAGRAPH, value = valueTail) self.peudodsnodereplace = dsnode return self.handleIndent(dsnode, xmlnode)
#Just testing text based games again import util import levelLoader import stats import inventory as inv while 1 == 1: currentLevel = util.getLevel() #print(currentLevel) action = raw_input("\nWhat do you want to do? ").lower() if action.replace("at", "in").replace(" your", "") == "look in inventory": inv.list() else: currentLevel.act(action) if stats.getHealth() < 1: print("You died.") exit(0)