tmt/utils.py
def load(self, text, version=None):
        """ Load the StructuredField from a string """
        if version is not None:
            self.version(version)
        # Make sure we got a text, convert to unicode if necessary
        try:
            if not isinstance(text, basestring):
                raise StructuredFieldError(
                        "Invalid StructuredField, expecting string or unicode")
            if not isinstance(text, unicode):
                text = text.decode("utf8")
        except NameError:
            if not isinstance(text, str):
                raise StructuredFieldError(
                        "Invalid StructuredField, expecting string")
        # Remove possible carriage returns
        text = re.sub("\r\n", "\n", text)
        # Make sure the text has a new line at the end
        if text and text[-1] != "\n":
            text += "\n"
        log.debug(u"Parsing StructuredField\n{0}".format(text))
        # Parse respective format version
        if self._version == 0:
            self._load_version_zero(text)
        else:
            self._load(text)
 Load the StructuredField from a string 
Load the StructuredField from a string
Load the StructuredField from a string
def load(self, text, version=None):
        if version is not None:
            self.version(version)
        try:
            if not isinstance(text, basestring):
                raise StructuredFieldError(
                        "Invalid StructuredField, expecting string or unicode")
            if not isinstance(text, unicode):
                text = text.decode("utf8")
        except NameError:
            if not isinstance(text, str):
                raise StructuredFieldError(
                        "Invalid StructuredField, expecting string")
        text = re.sub("\r\n", "\n", text)
        if text and text[-1] != "\n":
            text += "\n"
        log.debug(u"Parsing StructuredField\n{0}".format(text))
        if self._version == 0:
            self._load_version_zero(text)
        else:
            self._load(text)
def load ( self , text , version = None ) : if version is not None : self . version ( version ) try : if not isinstance ( text , basestring ) : raise StructuredFieldError ( "Invalid StructuredField, expecting string or unicode" ) if not isinstance ( text , unicode ) : text = text . decode ( "utf8" ) except NameError : if not isinstance ( text , str ) : raise StructuredFieldError ( "Invalid StructuredField, expecting string" ) text = re . sub ( "\r\n" , "\n" , text ) if text and text [ - 1 ] != "\n" : text += "\n" log . debug ( u"Parsing StructuredField\n{0}" . format ( text ) ) if self . _version == 0 : self . _load_version_zero ( text ) else : self . _load ( text )
Load the StructuredField from a string
Load the StructuredField from a string
""" Load the StructuredField from a string """ # Make sure we got a text, convert to unicode if necessary # Remove possible carriage returns # Make sure the text has a new line at the end # Parse respective format version
self
text
version