Skip to content

Commit e10becf

Browse files
authored
Merge pull request #104 from creativecommons/json_to_yaml
Replace JSON with YAML
2 parents 6e5cc84 + 91993b5 commit e10becf

File tree

9 files changed

+332
-256
lines changed

9 files changed

+332
-256
lines changed

normalize_repos/Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ allow_prereleases = true
88

99
[dev-packages]
1010
black = "*"
11+
ipython = "*"
1112

1213
[packages]
1314
pygithub = "*"

normalize_repos/Pipfile.lock

+181-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

normalize_repos/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This script ensures that all active repositories in the creativecommons GitHub
44
organization are consistent in the following ways:
5-
* They have all the labels defined in `labels.json` present.
5+
* They have all the labels defined in `labels.yml` present.
66
* They have standard branch protections set up (with some exceptions).
77

88
This script will only update color and description of existing labels or create

normalize_repos/get_labels.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Standard library
22
from pathlib import Path
3-
import json
3+
import yaml
44

55
# Local/library specific
66
from models import Group, Label
@@ -12,7 +12,7 @@ def get_standard_labels():
1212
@return: the list of standard labels
1313
"""
1414

15-
labels_dict = load_json_from_file("labels")
15+
labels_dict = load_yaml_from_file("labels")
1616
standard_labels = []
1717
for group_info in labels_dict["groups"]:
1818
label_names = group_info.pop("labels", [])
@@ -34,7 +34,7 @@ def get_repo_specific_labels():
3434
"""
3535

3636
skill_group = Group(color="5ff1f5", name="skill")
37-
labels_dict = load_json_from_file("skills")
37+
labels_dict = load_yaml_from_file("skills")
3838
repo_specific_labels = {}
3939
for repo_name, skill_names in labels_dict.items():
4040
skill_labels = [
@@ -63,31 +63,31 @@ def get_skill_label_from_name(skill_group, skill_name):
6363
)
6464

6565

66-
def load_json_from_file(file_name):
66+
def load_yaml_from_file(file_name):
6767
"""
68-
Load the JSON file into a Python list or dict. The extension '.json' is
68+
Load the YAML file into a Python list or dict. The extension '.yml' is
6969
appended to the file name and only the current directory is scanned for the
7070
matching file.
7171
@param file_name: the name of the file to load
72-
@return: the contents of the JSON file as a Python object
72+
@return: the contents of the YAML file as a Python object
7373
"""
7474

7575
file_path = get_datafile_path(file_name)
7676
with open(file_path, "r") as file:
77-
data = json.load(file)
77+
data = yaml.safe_load(file)
7878
return data
7979

8080

8181
def get_datafile_path(file_name):
8282
"""
8383
Get the path to the datafile by searching the current directory for a file
84-
with the given name and the '.json' extension.
84+
with the given name and the '.yml' extension.
8585
@param file_name: the name of the file whose path is required
8686
@return: the path to the file
8787
"""
8888

8989
current_file = Path(__file__).resolve()
90-
data_file = current_file.parent.joinpath(f"{file_name}.json")
90+
data_file = current_file.parent.joinpath(f"{file_name}.yml")
9191
return data_file
9292

9393

@@ -102,4 +102,4 @@ def get_labels():
102102
return standard_labels, repo_specific_labels
103103

104104

105-
__all__ = [get_labels]
105+
__all__ = ["get_labels"]

normalize_repos/labels.json

-177
This file was deleted.

normalize_repos/labels.yml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
groups:
2+
- name: priority
3+
is_required: true
4+
labels:
5+
- name: critical
6+
color: 'UNFAVOURABLE'
7+
description: Must be fixed ASAP
8+
emoji: "\uD83D\uDFE5"
9+
- name: high
10+
color: 'NEGATIVE'
11+
description: Stalls work on the project or its dependents
12+
emoji: "\uD83D\uDFE7"
13+
- name: medium
14+
color: 'NEUTRAL'
15+
description: Not blocking but should be fixed soon
16+
emoji: "\uD83D\uDFE8"
17+
- name: low
18+
color: 'POSITIVE'
19+
description: Low priority and doesn't need to be rushed
20+
emoji: "\uD83D\uDFE9"
21+
22+
- name: status
23+
is_required: true
24+
labels:
25+
- name: ready for work
26+
color: 'LIGHT'
27+
description: Ready for work
28+
emoji: "\uD83C\uDFC1"
29+
- name: blocked
30+
color: 'MEDIUM'
31+
description: Blocked & therefore, not ready for work
32+
emoji: "\uD83D\uDEA7"
33+
- name: ticket work required
34+
color: 'DARK'
35+
description: Needs more details before it can be worked on
36+
emoji: "\uD83E\uDDF9"
37+
- name: discarded
38+
color: 'LIGHTER'
39+
description: Will not be worked on
40+
emoji: '⛔️'
41+
- name: awaiting triage
42+
color: 'DARKER'
43+
description: Has not been triaged & therefore, not ready for work
44+
emoji: "\uD83D\uDEA6"
45+
46+
- name: goal
47+
color: 'ffffff'
48+
is_required: true
49+
labels:
50+
- name: addition
51+
description: Addition of new feature
52+
emoji: "\uD83C\uDF1F"
53+
- name: improvement
54+
description: Improvement to an existing feature
55+
emoji: ''
56+
- name: fix
57+
description: Bug fix
58+
emoji: "\uD83D\uDEE0"
59+
60+
- name: aspect
61+
color: '04338c'
62+
is_required: true
63+
labels:
64+
- name: text
65+
description: Concerns the textual material in the repository
66+
emoji: "\uD83D\uDCC4"
67+
- name: code
68+
description: Concerns the software code in the repository
69+
emoji: "\uD83D\uDCBB"
70+
- name: interface
71+
description: Concerns end-users' experience with the software
72+
emoji: "\uD83D\uDD79"
73+
- name: dx
74+
description: Concerns developers' experience with the codebase
75+
emoji: "\uD83E\uDD16"
76+
77+
- name: talk
78+
color: 'f9bbe5'
79+
labels:
80+
- name: question
81+
description: Can be resolved with an answer
82+
emoji: ''
83+
- name: discussion
84+
description: Open for discussions and feedback
85+
emoji: "\uD83D\uDCAC"
86+
87+
- name: friendliness
88+
color: '7f0799'
89+
is_prefixed: false
90+
labels:
91+
- name: good first issue
92+
description: New-contributor friendly
93+
emoji: "\uD83E\uDD17"
94+
has_emoji_name: false
95+
- name: help wanted
96+
description: Open to participation from the community
97+
emoji: "\uD83D\uDE4F"
98+
has_emoji_name: false
99+
- name: staff only
100+
description: Restricted to CC staff members
101+
emoji: "\uD83D\uDD12"
102+
103+
standalone:
104+
- name: 'ノಠ益ಠノ彡┻━┻'
105+
color: '000000'
106+
description: Aaargh!
107+
emoji: "\uD83E\uDD2F"
108+
109+
- name: Hacktoberfest
110+
color: '883255'
111+
description: Ideal for Hacktoberfest participation
112+
emoji: "\uD83C\uDF83"
113+
has_emoji_name: false
114+
115+
- name: invalid
116+
color: 'LIGHTER'
117+
description: Inappropriate or invalid (ex. Hacktoberfest spam)
118+
emoji: '⛔️'
119+
has_emoji_name: false
120+

0 commit comments

Comments
 (0)