File size: 947 Bytes
b382bd8
 
41b3337
 
 
b382bd8
 
 
 
41b3337
 
 
 
 
 
 
 
 
 
 
 
b382bd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# usage_tracker.py

from collections import Counter


# =====================================================
# BUILD USAGE MAP
# =====================================================

def build_usage_map(
    timeline
):

    usage = Counter()

    for scene in timeline:

        usage[
            scene["path"]
        ] += 1

    return dict(usage)


# =====================================================
# DECREASE USAGE
# =====================================================

def consume_scene(
    usage_map,
    scene
):

    path = scene["path"]

    if path not in usage_map:
        return False

    usage_map[path] -= 1

    return usage_map[path] <= 0


# =====================================================
# STATS
# =====================================================

def remaining_files(
    usage_map
):

    count = 0

    for value in usage_map.values():

        if value > 0:
            count += 1

    return count