diff options
author | 2019-07-06 23:51:09 +0100 | |
---|---|---|
committer | 2019-07-06 23:52:32 +0100 | |
commit | 73171d5a49c018e029f63ff6b5eb3736bbc709fd (patch) | |
tree | af468b8aad5cc7a1fbcedbbea7caf7770da0f14c /pydis_site/utils | |
parent | noqa the definition lines inside resources.py because flake8 does not support... (diff) |
Docstrings & prefix category info files with underscore for prominence
Diffstat (limited to 'pydis_site/utils')
-rw-r--r-- | pydis_site/utils/resources.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pydis_site/utils/resources.py b/pydis_site/utils/resources.py index 582df7f7..875c0dc9 100644 --- a/pydis_site/utils/resources.py +++ b/pydis_site/utils/resources.py @@ -14,6 +14,9 @@ class URL: class Resource: + """ + A class representing a resource on the resource page + """ description: str name: str payment: str @@ -40,6 +43,9 @@ class Resource: class Category: + """ + A class representing a resource on the resources page + """ resources: typing.List[Resource] name: str description: str @@ -51,7 +57,7 @@ class Category: def construct_from_directory(cls, directory: str) -> Category: # noqa category = cls() - with open(f"{directory}/category_info.yaml") as category_info: + with open(f"{directory}/_category_info.yaml") as category_info: category_data = yaml.safe_load(category_info) category.__dict__.update(category_data) @@ -59,7 +65,7 @@ class Category: category.resources = [] for resource in glob.glob(f"{directory}/*.yaml"): - if resource == f"{directory}/category_info.yaml": + if resource == f"{directory}/_category_info.yaml": continue with open(resource) as res_file: @@ -71,6 +77,10 @@ class Category: def load_categories(order: typing.List[str]) -> typing.List[Category]: + """ + Load the categories specified in the order list and return them + as a list. + """ categories = [] for cat in order: direc = "pydis_site/apps/home/resources/" + cat |