Exemple #1
0
 def __parse_xml_folder(self, xml_child, folder_entry):
     for child in xml_child:
         if child.tag == 'file':
             ef = entry.e_file(child.attrib['name'], folder_entry, False)
             ef.set_hash(child.attrib['hash'])
             ef.length = int(child.attrib['length'])
             folder_entry.add_child(ef)
         elif child.tag == 'folder':
             ed = entry.e_dir(child.attrib['name'], folder_entry)
             folder_entry.add_child(ed)
             self.__parse_xml_folder(child, ed)
Exemple #2
0
 def __scan_folder(self, folder_entry):
     folder_path = folder_entry.get_fullpath()
     files = os.listdir(folder_path)
     for f in files:
         #print f
         if not f.startswith('.'):
             fpath = os.path.join(folder_path, f)
             if os.path.isfile(fpath):
                 e = entry.e_file(f, folder_entry)
                 folder_entry.add_child(e)
             elif os.path.isdir(fpath):
                 e = entry.e_dir(f)
                 folder_entry.add_child(e)
                 self.__scan_folder(e)
Exemple #3
0
 def build_tree(self, root_path):
     self.root_path = root_path
     files = os.listdir(self.root_path)
     self.root = entry.root_entry(root_path)
     print "Scanning root index..."
     for f in files:
         #print f
         if not f.startswith('.'):
             fpath = os.path.join(self.root_path, f)
             if os.path.isfile(fpath):
                 e = entry.e_file(f, self.root)
                 self.root.add_child(e)
             elif os.path.isdir(fpath):
                 e = entry.e_dir(f)
                 self.root.add_child(e)
                 self.__scan_folder(e)
Exemple #4
0
    def from_xml(self, input):
        xml_tree = ET.parse(input)

        xml_root = xml_tree.getroot()

        if xml_root.tag == 'sufs_index': # todo put this into a constants
            for child in xml_root:
                if child.tag == 'root':
                    self.root = entry.root_entry()
                for ic in child:
                    if ic.tag == 'file':
                        ef = entry.e_file(ic.attrib['name'], self.root, False)
                        ef.set_hash(ic.attrib['hash'])
                        ef.length = int(ic.attrib['length'])
                        self.root.add_child(ef)
                    elif ic.tag == 'folder':
                        ed = entry.e_dir(ic.attrib['name'], self.root)
                        self.root.add_child(ed)
                        self.__parse_xml_folder(ic, ed)
Exemple #5
0
 def load_xml(self):
     fe = entry.e_file('index.xml')
     fi = file_instance.file_instance(fe)
     self.index_blocks = fi
     print "Blocks Count : %d" % fi.blocks_count()