Пример #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
            else:
                Executable = False
            self.Files.append([Filename, Executable, OsType])

        MiscFile = MiscFileObject()
        MiscFile.SetName(self.Header.Name)
        MiscFile.SetCopyright(self.Header.Copyright)
        MiscFile.SetLicense(self.Header.License)
        MiscFile.SetAbstract(self.Header.Abstract)
        MiscFile.SetDescription(self.Header.Description)
        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
 def FromXml(self, Item, Key):
     if not Item:
         return None
     self.Header.FromXml(Item, Key)
     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')
         if Executable.upper() == "TRUE":
             Executable = True
         elif Executable.upper() == "FALSE":
             Executable = False
         else:
             Executable = ''
         self.Files.append([Filename, Executable])
     MiscFile = MiscFileObject()
     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])
         MiscFileList.append(FileObj)
     MiscFile.SetFileList(MiscFileList)
     return MiscFile
 def GenMiscFiles(self, Content):
     MiscFileObj = MiscFileObject()
     for Line in Content.splitlines():
         FileName = ''
         if '#' in Line:
             FileName = Line[:Line.find('#')]
         else:
             FileName = Line
         if FileName:
             if IsValidPath(FileName, self.GetRelaPath()):
                 FileObj = FileObject()
                 FileObj.SetURI(FileName)
                 MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
             else:
                 Logger.Error("InfParser",
                              FORMAT_INVALID,
                              ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
                              File=self.GetFileName(),
                              ExtraData=Line)
     self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])