예제 #1
0
    def FromXml(self, Item, Key):
        self.UserId = XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId')
        self.Identifier = XmlAttribute(XmlNode(Item, '%s' % Key), 'Identifier')

        DefineItem = XmlNode(Item, '%s/Define' % Key)
        for SubItem in XmlList(DefineItem, 'Define/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            self.DefineDict[Statement] = ""

        BuildOptionItem = XmlNode(Item, '%s/BuildOption' % Key)
        for SubItem in XmlList(BuildOptionItem, 'BuildOption/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key),
                                'SupArchList')
            self.BuildOptionDict[Arch] = Statement

        IncludesItem = XmlNode(Item, '%s/Includes' % Key)
        for SubItem in XmlList(IncludesItem, 'Includes/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key),
                                'SupArchList')
            self.IncludesDict[Statement] = Arch

        SourcesItem = XmlNode(Item, '%s/Sources' % Key)
        Tmp = UserExtensionSourceXml()
        SourceDict = Tmp.FromXml(SourcesItem, 'Sources')
        self.SourcesDict = SourceDict

        BinariesItem = XmlNode(Item, '%s/Binaries' % Key)
        Tmp = UserExtensionBinaryXml()
        BinariesDict = Tmp.FromXml(BinariesItem, 'Binaries')
        self.BinariesDict = BinariesDict

        self.Statement = XmlElement(Item, 'UserExtensions')
        SupArch = XmlAttribute(XmlNode(Item, '%s' % Key), 'SupArchList')
        self.SupArchList = [
            Arch
            for Arch in GetSplitValueList(SupArch, DataType.TAB_SPACE_SPLIT)
            if Arch
        ]

        UserExtension = UserExtensionObject()
        UserExtension.SetUserID(self.UserId)
        UserExtension.SetIdentifier(self.Identifier)
        UserExtension.SetStatement(self.Statement)
        UserExtension.SetSupArchList(self.SupArchList)
        UserExtension.SetDefinesDict(self.DefineDict)
        UserExtension.SetBuildOptionDict(self.BuildOptionDict)
        UserExtension.SetIncludesDict(self.IncludesDict)
        UserExtension.SetSourcesDict(self.SourcesDict)
        UserExtension.SetBinariesDict(self.BinariesDict)

        return UserExtension
예제 #2
0
    def FromXml(self, Item, Key):
        self.UserId = XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId')
        self.Identifier = XmlAttribute(XmlNode(Item, '%s' % Key), 'Identifier')
        if self.UserId == DataType.TAB_BINARY_HEADER_USERID \
        and self.Identifier == DataType.TAB_BINARY_HEADER_IDENTIFIER:
            for SubItem in XmlList(Item, '%s/BinaryAbstract' % Key):
                BinaryAbstractLang = XmlAttribute(SubItem, 'Lang')
                self.BinaryAbstractList.append(
                    (BinaryAbstractLang,
                     XmlElement(SubItem, '%s/BinaryAbstract' % Key)))
            for SubItem in XmlList(Item, '%s/BinaryDescription' % Key):
                BinaryDescriptionLang = XmlAttribute(SubItem, 'Lang')
                self.BinaryDescriptionList.append(
                    (BinaryDescriptionLang,
                     XmlElement(SubItem, '%s/BinaryDescription' % Key)))
            for SubItem in XmlList(Item, '%s/BinaryCopyright' % Key):
                BinaryCopyrightLang = XmlAttribute(SubItem, 'Lang')
                self.BinaryCopyrightList.append(
                    (BinaryCopyrightLang,
                     XmlElement(SubItem, '%s/BinaryCopyright' % Key)))
            for SubItem in XmlList(Item, '%s/BinaryLicense' % Key):
                BinaryLicenseLang = XmlAttribute(SubItem, 'Lang')
                self.BinaryLicenseList.append(
                    (BinaryLicenseLang,
                     XmlElement(SubItem, '%s/BinaryLicense' % Key)))

        DefineItem = XmlNode(Item, '%s/Define' % Key)
        for SubItem in XmlList(DefineItem, 'Define/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            self.DefineDict[Statement] = ""
        BuildOptionItem = XmlNode(Item, '%s/BuildOption' % Key)
        for SubItem in XmlList(BuildOptionItem, 'BuildOption/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key),
                                'SupArchList')
            self.BuildOptionDict[Arch] = Statement
        IncludesItem = XmlNode(Item, '%s/Includes' % Key)
        for SubItem in XmlList(IncludesItem, 'Includes/Statement'):
            Statement = XmlElement(SubItem, '%s/Statement' % Key)
            Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key),
                                'SupArchList')
            self.IncludesDict[Statement] = Arch
        SourcesItem = XmlNode(Item, '%s/Sources' % Key)
        Tmp = UserExtensionSourceXml()
        SourceDict = Tmp.FromXml(SourcesItem, 'Sources')
        self.SourcesDict = SourceDict
        BinariesItem = XmlNode(Item, '%s/Binaries' % Key)
        Tmp = UserExtensionBinaryXml()
        BinariesDict = Tmp.FromXml(BinariesItem, 'Binaries')
        self.BinariesDict = BinariesDict
        self.Statement = XmlElement(Item, 'UserExtensions')
        SupArch = XmlAttribute(XmlNode(Item, '%s' % Key), 'SupArchList')
        self.SupArchList = [
            Arch
            for Arch in GetSplitValueList(SupArch, DataType.TAB_SPACE_SPLIT)
            if Arch
        ]
        UserExtension = UserExtensionObject()
        UserExtension.SetUserID(self.UserId)
        UserExtension.SetIdentifier(self.Identifier)
        UserExtension.SetBinaryAbstract(self.BinaryAbstractList)
        UserExtension.SetBinaryDescription(self.BinaryDescriptionList)
        UserExtension.SetBinaryCopyright(self.BinaryCopyrightList)
        UserExtension.SetBinaryLicense(self.BinaryLicenseList)
        UserExtension.SetStatement(self.Statement)
        UserExtension.SetSupArchList(self.SupArchList)
        UserExtension.SetDefinesDict(self.DefineDict)
        UserExtension.SetBuildOptionDict(self.BuildOptionDict)
        UserExtension.SetIncludesDict(self.IncludesDict)
        UserExtension.SetSourcesDict(self.SourcesDict)
        UserExtension.SetBinariesDict(self.BinariesDict)
        return UserExtension