def syncFromServer(self): """Update this Bot from the RPC server, if necessary. Right now the only task this performs is to store the server's ruleset if filterMode is 'unknown'. """ if self.filter_mode != FILTER.UNKNOWN: return ruleset = self._loadRuleset() if not ruleset: # If there's no ruleset, mark the bot as inactive. self.filter_mode = FILTER.INACTIVE self.save() return # Parse the ruleset using LibCIA's XML library from LibCIA import XML dom = XML.parseString(ruleset) # XXX: We should try to reduce the ruleset to one of # the other FILTER.* modes if possible. For now, # we'll always import existing rulesets as # FILTER.CUSTOM. # Flatten the contents of the <ruleset> element, clean up # the resulting text, and save that as a custom filter. text = ''.join([n.toxml() for n in dom.documentElement.childNodes]) self.filter_mode = FILTER.CUSTOM self.custom_ruleset = clean_up_text(text) self.save()
def param_noColor(self, tag): """The <noColor> parameter disables colors. This is equivalent to a <format> parameter with CommitFormatter's default component tree. """ self.componentTree = XML.parseString(CommitFormatter.defaultComponentTree ).documentElement
def param_noColor(self, tag): """The <noColor> parameter disables colors. This is equivalent to a <format> parameter with CommitFormatter's default component tree. """ self.componentTree = XML.parseString( CommitFormatter.defaultComponentTree).documentElement
def getSvnRevision(self): """Return the current Subversion repository revision, or None if we're not in an svn working copy or it can't be parsed. """ try: entries = XML.parseString(open(".svn/entries").read()).documentElement highestRev = 0 for tag in XML.getChildElements(entries): if tag.nodeName == 'entry': rev = tag.getAttributeNS(None, 'committed-rev') if rev and rev > highestRev: highestRev = rev return highestRev except: return None