Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LABELS-1] Add more labels #22

Merged
merged 10 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions labels/priority_labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: 'Priority: Critical'
color: '#7c0a02'
- name: 'Priority: High'
color: '#b22222'
- name: 'Priority: Medium'
color: '#e88a1a'
- name: 'Priority: Low'
color: '#f1bc31'
6 changes: 6 additions & 0 deletions labels/remove_default_labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- bug
- dependencies
- documentation
- enhancement
- github_actions
- question
8 changes: 0 additions & 8 deletions config/labels.yaml → labels/type_labels.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
- name: 'Priority: Critical'
color: '#7c0a02'
- name: 'Priority: High'
color: '#b22222'
- name: 'Priority: Medium'
color: '#e88a1a'
- name: 'Priority: Low'
color: '#f1bc31'
- name: 'Type: Bug'
color: '#d73a4a'
description: Something isn't working.
Expand Down
94 changes: 0 additions & 94 deletions scripts/_create_label_config.py

This file was deleted.

135 changes: 135 additions & 0 deletions scripts/_dump_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env python

"""
CLI helper script to create label config
in either json or yaml format
"""

__author__ = "seyLu"
__github__ = "github.com/seyLu"

__licence__ = "MIT"
__version__ = "0.0.1"
__maintainer__ = "seyLu"
__status__ = "Prototype"

import json
import logging
import os
from argparse import ArgumentParser, Namespace
from dataclasses import dataclass
from logging.config import fileConfig

import yaml

fileConfig("logging.ini")


@dataclass(frozen=True)
class LABELS:
REMOVE_DEFAULT: tuple[str, ...] = (
"bug",
"dependencies",
"documentation",
"enhancement",
"github_actions",
"question",
)
PRIORITY: tuple[dict[str, str], ...] = (
{
"name": "Priority: Critical",
"color": "#7c0a02",
},
{
"name": "Priority: High",
"color": "#b22222",
},
{
"name": "Priority: Medium",
"color": "#e88a1a",
},
{
"name": "Priority: Low",
"color": "#f1bc31",
},
)
TYPE: tuple[dict[str, str], ...] = (
{
"name": "Type: Bug",
"color": "#d73a4a",
"description": "Something isn't working.",
},
{
"name": "Type: Documentation",
"color": "#a2eeef",
"description": "Improvements or additions to documentation.",
},
{
"name": "Type: Feature Request",
"color": "#e88a1a",
"description": "Issue describes a feature or enhancement we'd like to implement.",
},
{
"name": "Type: Question",
"color": "#d876e3",
"description": "This issue doesn't require code. A question needs an answer.",
},
{
"name": "Type: Refactor/Clean-up",
"color": "#a0855b",
"description": "Issues related to reorganization/clean-up of data or code (e.g. for maintainability).",
},
{
"name": "Type: Suggestion",
"color": "#ac8daf",
},
)


if __name__ == "__main__":
LABELS_PATH: str = "labels"

parser: ArgumentParser = ArgumentParser()
parser.add_argument(
"--version",
"-v",
action="version",
version="%(prog)s 0.0.1",
)
parser.add_argument(
"--ext",
"-e",
choices=["json", "yaml"],
help="Specify a file extension",
)

args: Namespace = parser.parse_args()

EXT: str = args.ext or "yaml"

logging.info(f"Initializing {LABELS_PATH} dir.")
for filename in os.listdir(LABELS_PATH):
file_path: str = os.path.join(LABELS_PATH, filename)
if os.path.isfile(file_path):
os.remove(file_path)

for field in LABELS.__dataclass_fields__:
labels = getattr(LABELS, field)
labels_file: str = os.path.join(LABELS_PATH, f"{field.lower()}_labels.{EXT}")

with open(labels_file, "w+") as f:
logging.info(f"Dumping to {labels_file}.")

if EXT == "yaml":
print(
yaml.dump(
data=list(labels),
default_flow_style=False,
sort_keys=False,
),
file=f,
)
elif EXT == "json":
json.dump(labels, f, indent=2)

logging.info("Finished dumping of labels.")