Passed
Push — master ( d7aedc...c4fafb )
by Max
55s
created

mutmut_helper   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 8

2 Functions

Rating   Name   Duplication   Size   Complexity  
A cache_files() 0 11 5
A modified_files() 0 8 3
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