-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathutils.py
More file actions
35 lines (24 loc) · 1.01 KB
/
utils.py
File metadata and controls
35 lines (24 loc) · 1.01 KB
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
import pathlib
from ruamel.yaml import YAML
database_file = pathlib.Path(__file__).parent.parent / 'contributions.yaml'
def get_contributions():
# read in database yaml file
yaml = YAML()
with open(database_file, 'r') as db:
data = yaml.load(db)
contributions_list = data['contributions']
# filter contributions list, remove contribution status == BROKEN
contributions_list = [
contribution for contribution in contributions_list if contribution['status'] not in ["BROKEN", "DEPRECATED"]
]
return contributions_list
def apply_override(contributions_list):
# apply override. if field additional_category, add value to categories
for contribution in contributions_list:
if 'override' in contribution.keys():
for key in contribution['override'].keys():
contribution[key] = contribution['override'][key]
def get_valid_contributions():
contributions = get_contributions()
apply_override(contributions)
return contributions