Exemplo n.º 1
0
 def fromXml( xprofile ):
     """
     Restores the profile information from XML.
     
     :param      xprofile | <xml.etree.ElementTree.Element>
     
     :return     <XViewProfile>
     """
     # determine the proper version
     if xprofile.tag != 'profile':
         return XViewProfile()
     
     version = int(xprofile.get('version', '1'))
     
     # load the legacy information - just layout data
     if version == 1:
         prof = XViewProfile()
         prof.setXmlElement(xprofile)
         return prof
     
     # load latest information
     prof = XViewProfile()
     prof.setName(xprofile.get('name', ''))
     prof.setVersion(float(xprofile.get('profile_version', '1.0')))
     
     ico = xprofile.get('icon')
     if ico is not None:
         prof.setIcon(os.path.expandvars(ico))
     else:
         ico = xprofile.find('icon')
         if ico is not None:
             prof.setIcon(projexui.generatePixmap(ico.text))
     
     # restore data
     xdata = xprofile.find('data')
     if ( xdata is not None ):
         prof._customData = DataSet.fromXml(xdata)
     
     # load description
     xdesc = xprofile.find('desc')
     if ( xdesc is not None ):
         prof.setDescription(xdesc.text)
     
     # load layout
     xlayout = xprofile.find('layout')
     if ( xlayout is not None ):
         prof.setXmlElement(xlayout)
     
     return prof
Exemplo n.º 2
0
    def fromXml(xprofile):
        """
        Restores the profile information from XML.
        
        :param      xprofile | <xml.etree.ElementTree.Element>
        
        :return     <XViewProfile>
        """
        # determine the proper version
        if xprofile.tag != 'profile':
            return XViewProfile()

        version = int(xprofile.get('version', '1'))

        # load the legacy information - just layout data
        if version == 1:
            prof = XViewProfile()
            prof.setXmlElement(xprofile)
            return prof

        # load latest information
        prof = XViewProfile()
        prof.setName(xprofile.get('name', ''))
        prof.setVersion(float(xprofile.get('profile_version', '1.0')))

        ico = xprofile.get('icon')
        if ico is not None:
            prof.setIcon(os.path.expandvars(ico))
        else:
            ico = xprofile.find('icon')
            if ico is not None:
                prof.setIcon(projexui.generatePixmap(ico.text))

        # restore data
        xdata = xprofile.find('data')
        if (xdata is not None):
            prof._customData = DataSet.fromXml(xdata)

        # load description
        xdesc = xprofile.find('desc')
        if (xdesc is not None):
            prof.setDescription(xdesc.text)

        # load layout
        xlayout = xprofile.find('layout')
        if (xlayout is not None):
            prof.setXmlElement(xlayout)

        return prof
Exemplo n.º 3
0
 def fromXml( xprofile ):
     """
     Restores the profile information from XML.
     
     :param      xprofile | <xml.etree.ElementTree.Element>
     
     :return     <XViewProfile>
     """
     # determine the proper version
     if ( xprofile.tag != 'profile' ):
         return XViewProfile()
     
     version = int(xprofile.get('version', '1'))
     
     # load the legacy information - just layout data
     if ( version == 1 ):
         prof = XViewProfile()
         prof.setXmlElement(xprofile)
         return prof
     
     # load latest information
     prof = XViewProfile()
     prof.setName(xprofile.get('name', ''))
     prof.setIcon(xprofile.get('icon', ''))
     
     # restore data
     xdata = xprofile.find('data')
     if ( xdata is not None ):
         prof._customData = DataSet.fromXml(xdata)
     
     # load description
     xdesc = xprofile.find('desc')
     if ( xdesc is not None ):
         prof.setDescription(xdesc.text)
     
     # load layout
     xlayout = xprofile.find('layout')
     if ( xlayout is not None ):
         prof.setXmlElement(xlayout)
     
     return prof