def analyzeHTML(self, s): result = None if None == s: self._isHTML = False self.numberOfLinesHigh = 0 self.numberOfCharsWide = 0 elif hasattr(s, "startswith") and not s.startswith("<html>"): # no html==>plain text self._isHTML = False self.numberOfLinesHigh = 1 self.numberOfCharsWide = len(s) result = s else: # HTML self._isHTML = True # <html> is just a flag, not a tag, so strip it out. result = s[HTML_LEN:] if self.widthUpperBound == NAI: self.numberOfCharsWide = htmlWidth(result) if self.heightUpperBound == NAI: self.numberOfLinesHigh = htmlHeight(result) return result
def getNumberOfCharsWide(s): result = 0 if not s.startswith("<html>"): result = len(s) else: result = htmlWidth(s) return result