예제 #1
0
 def FromXml2(self, Item, Key):
     if Item is None:
         return None
     NewItem = XmlNode(Item, '%s/Header' % Key)
     self.Header.FromXml(NewItem, 'Header')
     for SubItem in XmlList(Item, '%s/Filename' % Key):
         Filename = XmlElement(SubItem, '%s/Filename' % Key)
         Executable = \
         XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'Executable')
         OsType = XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'OS')
         if Executable.upper() == "TRUE":
             Executable = True
         elif Executable.upper() == "FALSE":
             Executable = False
         else:
             Executable = ''
         self.Files.append([Filename, Executable, OsType])
     MiscFile = MiscFileObject()
     MiscFile.SetName(self.Header.Name)
     MiscFile.SetCopyright(self.Header.CopyrightList)
     MiscFile.SetLicense(self.Header.LicenseList)
     MiscFile.SetAbstract(self.Header.AbstractList)
     MiscFile.SetDescription(self.Header.DescriptionList)
     MiscFileList = []
     for File in self.Files:
         FileObj = FileObject()
         FileObj.SetURI(File[0])
         FileObj.SetExecutable(File[1])
         FileObj.SetOS(File[2])
         MiscFileList.append(FileObj)
     MiscFile.SetFileList(MiscFileList)
     return MiscFile
예제 #2
0
class DistributionPackageHeaderXml(object):
    def __init__(self):
        self.Header = HeaderXml()
        self.ReadOnly = ''
        self.RePackage = ''
        self.Vendor = ''
        self.Date = ''
        self.Signature = ''
        self.XmlSpecification = ''

    def FromXml(self, Item, Key):
        if not Item:
            return None
        self.ReadOnly = XmlAttribute(XmlNode(Item, '%s' % Key), 'ReadOnly')
        self.RePackage = XmlAttribute(XmlNode(Item, '%s' % Key), 'RePackage')
        self.Vendor = XmlElement(Item, '%s/Vendor' % Key)
        self.Date = XmlElement(Item, '%s/Date' % Key)
        self.Signature = XmlElement(Item, '%s/Signature' % Key)
        self.XmlSpecification = XmlElement(Item, '%s/XmlSpecification' % Key)
        self.Header.FromXml(Item, Key)
        DistributionPackageHeader = DistributionPackageHeaderObject()
        if self.ReadOnly.upper() == 'TRUE':
            DistributionPackageHeader.ReadOnly = True
        elif self.ReadOnly.upper() == 'FALSE':
            DistributionPackageHeader.ReadOnly = False
        if self.RePackage.upper() == 'TRUE':
            DistributionPackageHeader.RePackage = True
        elif self.RePackage.upper() == 'FALSE':
            DistributionPackageHeader.RePackage = False
        DistributionPackageHeader.Vendor = self.Vendor
        DistributionPackageHeader.Date = self.Date
        DistributionPackageHeader.Signature = self.Signature
        DistributionPackageHeader.XmlSpecification = self.XmlSpecification
        DistributionPackageHeader.SetName(self.Header.Name)
        DistributionPackageHeader.SetBaseName(self.Header.BaseName)
        DistributionPackageHeader.SetGuid(self.Header.GUID)
        DistributionPackageHeader.SetVersion(self.Header.Version)
        DistributionPackageHeader.SetCopyright(self.Header.CopyrightList)
        DistributionPackageHeader.SetLicense(self.Header.LicenseList)
        DistributionPackageHeader.SetAbstract(self.Header.AbstractList)
        DistributionPackageHeader.SetDescription(self.Header.DescriptionList)
        return DistributionPackageHeader

    def ToXml(self, DistributionPackageHeader, Key):
        if self.Header:
            pass
        Element1 = CreateXmlElement('Name', \
                                    DistributionPackageHeader.GetName(), [], \
                                    [['BaseName', \
                                    DistributionPackageHeader.GetBaseName()]])
        Element2 = CreateXmlElement('GUID', \
                                    DistributionPackageHeader.GetGuid(), [], \
                                    [['Version', \
                                    DistributionPackageHeader.GetVersion()]])
        AttributeList = []
        if DistributionPackageHeader.ReadOnly != '':
            AttributeList.append(['ReadOnly', str(DistributionPackageHeader.ReadOnly).lower()])
        if DistributionPackageHeader.RePackage != '':
            AttributeList.append(['RePackage', str(DistributionPackageHeader.RePackage).lower()])
        if DistributionPackageHeader.GetAbstract():
            DPAbstract = DistributionPackageHeader.GetAbstract()[0][1]
        else:
            DPAbstract = ''
        if DistributionPackageHeader.GetDescription():
            DPDescription = DistributionPackageHeader.GetDescription()[0][1]
        else:
            DPDescription = ''
        if DistributionPackageHeader.GetCopyright():
            DPCopyright = DistributionPackageHeader.GetCopyright()[0][1]
        else:
            DPCopyright = ''
        if DistributionPackageHeader.GetLicense():
            DPLicense = DistributionPackageHeader.GetLicense()[0][1]
        else:
            DPLicense = ''
        NodeList = [Element1,
                    Element2,
                    ['Vendor', DistributionPackageHeader.Vendor],
                    ['Date', DistributionPackageHeader.Date],
                    ['Copyright', DPCopyright],
                    ['License', DPLicense],
                    ['Abstract', DPAbstract],
                    ['Description', DPDescription],
                    ['Signature', DistributionPackageHeader.Signature],
                    ['XmlSpecification', \
                     DistributionPackageHeader.XmlSpecification],
                    ]
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
        return Root

    def __str__(self):
        return "ReadOnly = %s RePackage = %s Vendor = %s Date = %s \
        Signature = %s XmlSpecification = %s %s" % \
        (self.ReadOnly, self.RePackage, self.Vendor, self.Date, \
         self.Signature, self.XmlSpecification, self.Header)