Example #1
0
 def create_from_file(self,
                      name,
                      filepath,
                      compress=True,
                      adjust_separator=True):
     """
     Prepare the FileEntry to receive data from an on-disk file to be packed
     :param name: filename used in the .pac directory
     :param filepath: path of the file to be imported
     :param compress:
     :param adjust_separator:
     :return:
     """
     if adjust_separator:
         self.name = adjust_separator_for_pac(name)
     else:
         self.name = name
     self.size = os.path.getsize(filepath)
     self.import_from = filepath
     if compress > 0:
         self.compressed = True
         self.compr_object = compression.Chuunicomp()
         chunknum = max(
             1,
             int(math.ceil(self.size /
                           self.compr_object.default_chunksize)))
         self.compr_object.fromFutureImport(chunknum)
 def search_file(self, name, exact_match=True, adjust_separator=True):
     """ :return: list of file ids """
     ret = []
     if adjust_separator:
         name = adjust_separator_for_pac(name)
     for file in self.files:
         if exact_match:
             if file.name == name:
                 ret.append(file.id)
         else:
             if file.name.startswith(name):
                 ret.append(file.id)
     return ret
Example #3
0
 def search_file(self, name, exact_match=True, adjust_separator=True):
     """ :return: list of file ids """
     ret = []
     if adjust_separator:
         name = adjust_separator_for_pac(name)
     for file in self.files:
         if exact_match:
             if file.name == name:
                 ret.append(file.id)
         else:
             if file.name.startswith(name):
                 ret.append(file.id)
     return ret
 def create_from_file(self, name, filepath, compress=True, adjust_separator=True):
     """
     Prepare the FileEntry to receive data from an on-disk file to be packed
     :param name: filename used in the .pac directory
     :param filepath: path of the file to be imported
     :param compress:
     :param adjust_separator:
     :return:
     """
     if adjust_separator:
         self.name = adjust_separator_for_pac(name)
     else:
         self.name = name
     self.size = os.path.getsize(filepath)
     self.import_from = filepath
     if compress > 0:
         self.compressed = True
         self.compr_object = compression.Chuunicomp()
         chunknum = max(1, int(math.ceil(self.size / self.compr_object.default_chunksize)))
         self.compr_object.fromFutureImport(chunknum)