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

fix for overlayed SD folder line #21

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
*~
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
11 changes: 6 additions & 5 deletions create_requirement_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions get_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
Loading