diff options
author | 2022-02-02 00:15:44 +0100 | |
---|---|---|
committer | 2022-02-02 00:15:44 +0100 | |
commit | 09fb2a4df59be324fc41176227ae3c684e2f6add (patch) | |
tree | 9d5baa069f91419e3189115d143129b6dc4b8e31 /pydis_site/apps/resources/utils.py | |
parent | Merge pull request #649 from python-discord/update-pyfakefs (diff) | |
parent | Duck pond removed when removing all filters. (diff) |
Merge pull request #582 from python-discord/swfarnsworth/smarter-resources/merge-with-main
Smarter Resources
Diffstat (limited to 'pydis_site/apps/resources/utils.py')
-rw-r--r-- | pydis_site/apps/resources/utils.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/pydis_site/apps/resources/utils.py b/pydis_site/apps/resources/utils.py deleted file mode 100644 index 1855fc80..00000000 --- a/pydis_site/apps/resources/utils.py +++ /dev/null @@ -1,42 +0,0 @@ -import typing as t -from pathlib import Path - -import yaml - - -def get_resources(path: Path) -> t.List[t.Dict]: - """Loads resource YAMLs from provided path.""" - resources = [] - - for item in path.iterdir(): - if item.is_file() and item.suffix == ".yaml" and item.name != "_category_info.yaml": - resources.append(yaml.safe_load(item.read_text())) - - return resources - - -def get_subcategories(path: Path) -> t.List[t.Dict]: - """Loads resources subcategories with their resources by provided path.""" - subcategories = [] - - for item in path.iterdir(): - if item.is_dir() and item.joinpath("_category_info.yaml").exists(): - subcategories.append({ - "category_info": { - **yaml.safe_load( - item.joinpath("_category_info.yaml").read_text() - ), - "raw_name": item.name - }, - "resources": [ - yaml.safe_load(subitem.read_text()) - for subitem in item.iterdir() - if ( - subitem.is_file() - and subitem.suffix == ".yaml" - and subitem.name != "_category_info.yaml" - ) - ] - }) - - return subcategories |