コード例 #1
0
 def extract(self):
     members = self.zf.infolist()
     if self.show_info:
         self.start_extract()
     total = 0
     for zip_info in members:
         total += zip_info.file_size
         if not self.regex_util or not self.regex_util.do_match(spit_filename(zip_info.filename, True)):
             if len(zip_info.filename) + len(self.work_path) + 1 < 255:
                 self.zf.extract(zip_info.filename, self.work_path)
                 if self.eu_text and spit_filename(zip_info.filename, True) == "important.properties":
                     file_path = os.path.join(self.work_path, zip_info.filename)
                     try:
                         cf = MyConfigParser(file_path, file_error=True)
                         regrex = ["\$\{" + key + "\}" for key in cf.keys()]
                         self.eu_text.add_regex(regrex)
                     except Exception as exe:
                         print exe
                         print self.work_path + "/" + zip_info.filename
                 if self.show_info:
                     self.update_extract(total)
             else:
                 print "path len > 255   ", self.work_path, zip_info.filename
         else:
             pass
     if self.show_info:
         self.finish_extract()
     self.zf.close()
コード例 #2
0
 def __init__(self, zip_file_path, work_path, config_path, show_extract_progress=False, analyze_info=None,
              extract_progress=None):
     self.zip_file_path = zip_file_path
     self.work_path = work_path + os.sep + spit_filename(zip_file_path) + os.sep
     self.show_extract_progress = show_extract_progress
     self.is_extract_root = False
     self.extract_progress = extract_progress
     self.analyze_info = analyze_info
     self.cf = MyConfigParser(config_path, encoding="UTF-8")
     self.eu_file = ConfigRegexUtil(self.cf, "exclude_file")
     self.eu_text = ConfigRegexUtil(self.cf, "exclude_txt")
     self.search_regex = ConfigRegexUtil(self.cf, "search_regex")
コード例 #3
0
 def __walk(self, file_path):
     if not self.is_extract_root:
         self.is_extract_root = True
         self.__extract_root()
     walk_res = os.walk(file_path)
     for dir_path, dir_names, file_names in walk_res:
         for file_name in file_names:
             abs_file_path = os.path.join(dir_path, file_name)
             ext = spit_ext(abs_file_path)
             if ext == "jar":
                 if not self.eu_file.do_match(file_name):
                     jar_extract_path = dir_path + os.sep + spit_filename(file_name)
                     ef = self.make_extract(abs_file_path, jar_extract_path)
                     ef.clean_work_path()
                     ef.extract()
                     self.__walk(jar_extract_path)
             else:
                 if not self.eu_file.do_match(file_name):
                     self.analyze_file(abs_file_path)