| Total Complexity | 8 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import os.path |
||
| 2 | import subprocess |
||
| 3 | |||
| 4 | |||
| 5 | def modified_files(): |
||
| 6 | for file_ in ( |
||
| 7 | subprocess.run(["hg", "status", "--modified"], capture_output=True) |
||
| 8 | .stdout.decode() |
||
| 9 | .split("\n") |
||
| 10 | ): |
||
| 11 | if file_: |
||
| 12 | yield file_[2:] |
||
| 13 | |||
| 14 | |||
| 15 | def cache_files(file_list): |
||
| 16 | for file_ in file_list: |
||
| 17 | dirname, fn = os.path.split(file_) |
||
| 18 | cache_dir = os.path.join(dirname, "__pycache__") |
||
| 19 | try: |
||
| 20 | cache_files = os.listdir(cache_dir) |
||
| 21 | except FileNotFoundError: |
||
| 22 | continue |
||
| 23 | for cache_file in cache_files: |
||
| 24 | if cache_file.startswith(fn): |
||
| 25 | yield os.path.join(cache_dir, cache_file) |
||
| 26 | |||
| 27 | |||
| 28 | if __name__ == "__main__": |
||
| 29 | for cache_file in cache_files(modified_files()): |
||
| 30 | print(cache_file) |
||
| 31 | os.remove(cache_file) |
||
| 32 |