Example #1
0
 def load_entry(self, line):
   line = line.strip()
   # path
   pos = line.find(':')
   if pos == -1:
     raise IOError("Invalid xdfmeta file! (no colon in line)")
   path = line[:pos]
   # prot
   line = line[pos+1:]
   pos = line.find(',')
   if pos == -1:
     raise IOError("Invalid xdfmeta file! (no first comma)")
   prot_str = line[:pos]
   prot = ProtectFlags()
   prot.parse(prot_str)
   # time
   line = line[pos+1:]
   pos = line.find(',')
   if pos == -1:
     raise IOError("Invalid xdfmeta file! (no second comma)")
   time_str = line[:pos]
   time = TimeStamp()
   time.parse(time_str)
   # comment
   comment = line[pos+1:]
   # meta info
   mi = MetaInfo(protect_flags=prot, mod_ts=time, comment=comment)
   self.set_meta_info(path, mi)
Example #2
0
 def load_entry(self, line):
     line = line.strip()
     # path
     pos = line.find(':')
     if pos == -1:
         raise IOError("Invalid xdfmeta file! (no colon in line)")
     path = line[:pos].decode("UTF-8")
     # prot
     line = line[pos + 1:]
     pos = line.find(',')
     if pos == -1:
         raise IOError("Invalid xdfmeta file! (no first comma)")
     prot_str = line[:pos]
     prot = ProtectFlags()
     prot.parse(prot_str)
     # time
     line = line[pos + 1:]
     pos = line.find(',')
     if pos == -1:
         raise IOError("Invalid xdfmeta file! (no second comma)")
     time_str = line[:pos]
     time = TimeStamp()
     time.parse(time_str)
     # comment
     comment = FSString(line[pos + 1:].decode("UTF-8"))
     # meta info
     mi = MetaInfo(protect_flags=prot, mod_ts=time, comment=comment)
     self.set_meta_info(path, mi)
Example #3
0
    def pack_entry(self, in_path, parent_node):
        ami_name = self.from_path_str(os.path.basename(in_path))
        # retrieve meta info for path from DB
        if self.meta_db != None:
            ami_path = parent_node.get_node_path_name().get_unicode()
            if ami_path != u"":
                ami_path += u"/" + ami_name
            else:
                ami_path = ami_name
            meta_info = self.meta_db.get_meta_info(ami_path)
        else:
            meta_info = MetaInfo()  # thor mod
            protect = ProtectFlags()
            protect.fromPath(in_path)
            meta_info.set_protect_flags(protect)
            meta_info.set_mod_time(os.path.getmtime(in_path))

        # pack directory
        if os.path.isdir(in_path):
            node = parent_node.create_dir(FSString(ami_name), meta_info, False)
            for name in os.listdir(in_path):
                sub_path = os.path.join(in_path, name)
                self.pack_entry(sub_path, node)
            node.flush()
        # pack file
        elif os.path.isfile(in_path):
            # read file
            fh = open(in_path, "rb")
            data = fh.read()
            fh.close()
            node = parent_node.create_file(FSString(ami_name), data, meta_info,
                                           False)
            node.flush()
            self.total_bytes += len(data)
Example #4
0
 def change_protect_by_string(self, pr_str):
     p = ProtectFlags()
     p.parse(pr_str)
     self.change_protect(p.mask)
Example #5
0
 def change_protect_by_string(self, pr_str):
   p = ProtectFlags()
   p.parse(pr_str)
   self.change_protect(p.mask)