def unescape(string): '''Unescape the & escapes in html, like " returns a string ''' string = string.replace(""", "\"") #Not done by xml lib string = xmlunescape(string) return string
def tostr(self, fmt=default_format): '''Format the tweet to string according to a template. fmt: the template. Fields are enclosed by << and >>. For example, \ <<user.screen_name>> will be replace by the screen name of \ author. A full list of fields are described in \ http://dev.twiiter.com/doc/get/statuses/user_timeline. \ Default to NeuTweet.default_format.\ Returns a String. ''' return xmlunescape(\ re.sub("<<([a-z0-9A-Z._\-]+)>>", self._repl, fmt))
def characters(self, content): try: self.current.appendData(xmlunescape(content)) except Exception as e: raise type(e)("line %d: %s" % (self._locator.getLineNumber(), str(e)))
def decode(self, val, unesc): if unesc in ("xml", "*"): val = xmlunescape(val) if unesc in ("json", "*"): val = val.replace("\\/", "/") return val
def characters(self, content): # Discard character data for all elements except those for # which it is meaningful. if self.current.tagName in (Comment.tagName, Dim.tagName, Param.tagName, Stream.tagName, Time.tagName): self.current.appendData(xmlunescape(content))