获取需要扫描的代码文件和资源文件列表
(self, root_dir, code_suffixs, res_suffixs)
| 59 | return rules |
| 60 | |
| 61 | def __get_scan_files(self, root_dir, code_suffixs, res_suffixs): |
| 62 | """获取需要扫描的代码文件和资源文件列表 |
| 63 | """ |
| 64 | root_dir = root_dir.rstrip('\\/') |
| 65 | code_files = set() |
| 66 | res_files = set() |
| 67 | for dirpath, _, filenames in os.walk(root_dir): |
| 68 | for f in filenames: |
| 69 | if f.lower().endswith(code_suffixs): |
| 70 | fullpath = os.path.join(dirpath, f).replace(os.sep, '/') |
| 71 | code_files.add(fullpath) |
| 72 | if f.lower().endswith(res_suffixs) and '.bundle' not in dirpath: # 过滤掉.bundle第三方目录中的资源 |
| 73 | fullpath = os.path.join(dirpath, f).replace(os.sep, '/') |
| 74 | res_files.add(fullpath) |
| 75 | code_files = list(code_files) |
| 76 | res_files = list(res_files) |
| 77 | return code_files, res_files |
| 78 | |
| 79 | def __format_file_name(self, res_file_path, reg_num_ptn): |
| 80 | """对文件路径进行处理,只截取代码引用时会出现的字符串部分 |