def image_file_dump(fname, show = False): # set number labels with open(fname, 'rb') as file: allLines = file.read() num_of_item = 0 for item in allLines[ 4: 8]: num_of_item = (num_of_item << 8 | ord(item)) row_of_item = 0 for item in allLines[ 8:12]: row_of_item = (row_of_item << 8 | ord(item)) col_of_item = 0 for item in allLines[12:16]: col_of_item = (col_of_item << 8 | ord(item)) for i in range(0, num_of_item): prg.show_progress(i, num_of_item-1) offset = 16 min_coodinate = i *row_of_item*col_of_item+offset max_coodinate = (i+1)*row_of_item*col_of_item+offset obj_dump(allLines[min_coodinate:max_coodinate], fname + str(i) + '.dump') if show: for j in range(0, row_of_item*col_of_item): if ord(allLines[j+i*row_of_item*col_of_item+16]) > 0.: print '#', else : print ' ', if j%row_of_item == 0 : print ''
def get_un_use_code_files(a_project_path, a_zh_un_check_enable): c__dir = Dir(a_project_path) c_files = c__dir.files() h_files = [] check_files = [] for c_file in c_files: match = False if a_zh_un_check_enable: match = zhPattern.search(unicode(c_file.name)) not_system_file = ('xcodeproj' not in c_file.name) and ('xcworkspace' not in c_file.name) not_node_module = 'node_modules' not in c_file.path if 'Pod' not in c_file.path and ( not match) and not_system_file and not_node_module: is_png = 'png' == c_file.get_extension() is_jpg = 'jpg' == c_file.get_extension() if not (is_jpg or is_png): check_files.append(c_file) # 过滤pod if 'h' == c_file.get_extension(): h_files.append(c_file) i = 0 progress_index = 0 total = len(h_files) print("Total \'.h\' Files Count:%d" % total) while i < len(h_files): progress_index += 1 progress.show_progress(progress_index, total) h_file = h_files[i] contain = has_code_file_contain(h_file, check_files) if contain: i -= 1 h_files.remove(h_file) i += 1 return h_files
if arguments["-o"]: output_dir = arguments["-o"] #sids = ["dccd:527", "dccd:849"] sids = [] if arguments["-f"]: sid_file = arguments["-f"] print "Reading id's from: " + sid_file sids = [line.strip() for line in open(sid_file)] elif arguments["<id>"]: sids = arguments["<id>"] print "Downloading from: " + restURL print "Saving in: " + output_dir # actual downloading num_sids = len(sids) sid_cnt = 0 #print "id's: " + ", ".join(sids) print "Start downloading %s files..." % num_sids for sid in sids: download(restURL, username, password, sid, output_dir) sid_cnt += 1 progress.show_progress(sid_cnt, num_sids) print "Done" # invalid options except docopt.DocoptExit as e: print e.message
def get_un_use_images(a_project_path, a_zh_un_check_enable, image_analyse_check_as_line=False): c__dir = Dir(a_project_path) c_files = c__dir.files() img_files = [] check_files = [] for c_file in c_files: match = False if a_zh_un_check_enable: match = zhPattern.search(unicode(c_file.name)) not_system_file = ('xcodeproj' not in c_file.name) and ('xcworkspace' not in c_file.name) not_node_module = 'node_modules' not in c_file.path if 'Pod' not in c_file.path and ( not match) and not_system_file and not_node_module: is_png = 'png' == c_file.get_extension() is_jpg = 'jpg' == c_file.get_extension() if is_png or is_jpg: is_app_icon = 'AppIcon' in c_file.path is_launch = 'LaunchImage' in c_file.path if not (is_app_icon or is_launch): img_files.append(c_file) else: check_files.append(c_file) i = 0 progress_index = 0 count = len(img_files) print("Total Image Files Count: %d" % len(check_files)) while i < len(img_files): progress_index += 1 progress.show_progress(progress_index, count) # 逐文件排查 img_file = img_files[i] contain = False if not isinstance(img_file, File): contain = True else: image_name = img_file.name.partition('.')[0] if "@2x" in image_name or "@3x" in image_name: image_name = image_name.partition('@')[0] for check_file in check_files: if 'js' == check_file.get_extension(): simple_contain_str = img_file.name if "@2x" in simple_contain_str: simple_contain_str = simple_contain_str.replace( "@2x", "") if "@3x" in simple_contain_str: simple_contain_str = simple_contain_str.replace( "@3x", "") contain = check_file.has_contain( simple_contain_str, image_analyse_check_as_line) if contain: break # Json 内部查找,并且过滤到 .xcassets 内的 Content.json 的配置文件 if 'json' in check_file.name and 'Content' not in check_file.name: # 查找 json 串 "image_name" simple_contain_str = "\"" + image_name + "\"" contain = check_file.has_contain( simple_contain_str, image_analyse_check_as_line) if contain: break # 查找json 串:\"image_name\" simple_contain_str = "\\\"" + image_name + "\\\"" contain = check_file.has_contain( simple_contain_str, image_analyse_check_as_line) if contain: break else: # 查找 @"image_name" contain_str = "@\"" + image_name + "\"" contain = check_file.has_contain( contain_str, image_analyse_check_as_line) if contain: break if contain: img_files.remove(img_file) else: i += 1 return img_files