()
| 173 | |
| 174 | |
| 175 | def read_whitelist_file(): |
| 176 | ensure_whitelist_file() |
| 177 | paths = [] |
| 178 | exts = [] |
| 179 | try: |
| 180 | with open(WHITELIST_PATH, encoding="utf-8") as f: |
| 181 | for line in f: |
| 182 | line = line.strip() |
| 183 | if not line or line.startswith('#'): |
| 184 | continue |
| 185 | if line.startswith('.') or (not os.path.sep in line and len(line) <= 8): |
| 186 | exts.append(normalize_ext(line)) |
| 187 | else: |
| 188 | paths.append(os.path.abspath(os.path.expandvars(line))) |
| 189 | except Exception: |
| 190 | logging.exception("读取白名单失败") |
| 191 | return paths, exts |
| 192 | |
| 193 | |
| 194 | def ensure_config_defaults(config): |
no test coverage detected