mot / usage_tracker.py
digidau's picture
Update usage_tracker.py
b382bd8 verified
Raw
History Blame Contribute Delete
947 Bytes
# 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