diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 64022c0..cb67b70 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -16,7 +16,7 @@ jobs: - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: images path: generated_images diff --git a/.gitignore b/.gitignore index 7515470..ad2a4eb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,15 @@ __pycache__ latest_bundle_data.json latest_bundle_tag.json generated_images + +# Virtual environment-specific files +.env +.venv + +# MacOS-specific files +*.DS_Store + +# IDE-specific files +.idea +.vscode +*~ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e92c2a..ddf2cd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: hooks: - id: black - repo: https://github.com/fsfe/reuse-tool - rev: v0.12.1 + rev: v1.1.2 hooks: - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: pylint-2.7.1 + rev: v3.2.7 hooks: - id: pylint name: pylint (library code) diff --git a/README.md b/README.md index 46a4ff4..80e616d 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,14 @@ It will create images in the `generated_images` directory. ### Generate Single Learn Guide Image ```shell -python3 create_requirement_images.py --guide [Learn Guide Name] +python3 create_requirement_images.py learn --guide [Learn Guide Name] # OR -python3 create_requirement_images.py -g [Learn Guide Name] +python3 create_requirement_images.py learn -g [Learn Guide Name] +``` + +### Help Command +The help command will list all possible commands and arguments. + +```shell +python3 create_requirement_images.py --help ``` diff --git a/create_requirement_images.py b/create_requirement_images.py index 40d4980..15037a9 100755 --- a/create_requirement_images.py +++ b/create_requirement_images.py @@ -38,9 +38,8 @@ TEXT_COLOR = "#B0B0B0" HIDDEN_TEXT_COLOR = "#808080" -f = open("latest_bundle_data.json", "r") -bundle_data = json.load(f) -f.close() +with open("latest_bundle_data.json", "r", encoding="utf-8") as f: + bundle_data = json.load(f) def asset_path(asset_name): @@ -415,14 +414,16 @@ def make_sd_dir(position): PADDING + (LINE_SPACING * (7 + project_files_count)), ) make_libraries(final_list_to_render, _libraries_position) + _sd_dir_position = ( 76, PADDING - + (LINE_SPACING * (7 + project_files_count + len(final_list_to_render))), + + (LINE_SPACING * (7 + project_files_count + len(final_list_to_render))) + + (1 if context["added_settings_toml"] else 0) * LINE_SPACING, ) make_sd_dir(_sd_dir_position) - img.save("generated_images/{}.png".format(image_name)) + img.save(f"generated_images/{image_name}.png") def generate_learn_requirement_image( # pylint: disable=invalid-name diff --git a/get_imports.py b/get_imports.py index d4b2ad8..ea6a03e 100644 --- a/get_imports.py +++ b/get_imports.py @@ -116,14 +116,14 @@ def ensure_latest_bundle(): ensure_latest_bundle() -with open("latest_bundle_data.json", "r") as f: +with open("latest_bundle_data.json", "r", encoding="utf-8") as f: bundle_data = json.load(f) def get_files_for_project(project_name): """Get the set of files for a learn project""" found_files = set() - project_dir = "{}/{}/".format(LEARN_GUIDE_REPO, project_name) + project_dir = f"{LEARN_GUIDE_REPO}/{project_name}/" full_tree = os.walk(project_dir) root_level = next(full_tree) @@ -153,11 +153,11 @@ def get_libs_for_project(project_name): """Get the set of libraries for a learn project""" found_libs = set() found_imports = [] - project_dir = "{}{}/".format(LEARN_GUIDE_REPO, project_name) + project_dir = f"{LEARN_GUIDE_REPO}{project_name}/" for file in os.listdir(project_dir): if file.endswith(".py"): - found_imports = findimports.find_imports("{}{}".format(project_dir, file)) + found_imports = findimports.find_imports(f"{project_dir}{file}") for cur_import in found_imports: cur_lib = cur_import.name.split(".")[0]