Skip to content

Commit 0301b12

Browse files
committed
Merge branch 'refs/heads/main' into include_community_bundle_libs
# Conflicts: # get_imports.py
2 parents 027b248 + 0dd5ea6 commit 0301b12

File tree

6 files changed

+34
-14
lines changed

6 files changed

+34
-14
lines changed

Diff for: .github/workflows/build-images.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- run: python3 -mpip install -r requirements.txt
1717
- run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn
1818
- run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py
19-
- uses: actions/upload-artifact@v2
19+
- uses: actions/upload-artifact@v4
2020
with:
2121
name: images
2222
path: generated_images

Diff for: .gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@ __pycache__
66
latest_bundle_data.json
77
latest_bundle_tag.json
88
generated_images
9+
10+
# Virtual environment-specific files
11+
.env
12+
.venv
13+
14+
# MacOS-specific files
15+
*.DS_Store
16+
17+
# IDE-specific files
18+
.idea
19+
.vscode
20+
*~

Diff for: .pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
hooks:
99
- id: black
1010
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v0.12.1
11+
rev: v1.1.2
1212
hooks:
1313
- id: reuse
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -18,7 +18,7 @@ repos:
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
2020
- repo: https://github.com/pycqa/pylint
21-
rev: pylint-2.7.1
21+
rev: v3.2.7
2222
hooks:
2323
- id: pylint
2424
name: pylint (library code)

Diff for: README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ It will create images in the `generated_images` directory.
2020
### Generate Single Learn Guide Image
2121

2222
```shell
23-
python3 create_requirement_images.py --guide [Learn Guide Name]
23+
python3 create_requirement_images.py learn --guide [Learn Guide Name]
2424
# OR
25-
python3 create_requirement_images.py -g [Learn Guide Name]
25+
python3 create_requirement_images.py learn -g [Learn Guide Name]
26+
```
27+
28+
### Help Command
29+
The help command will list all possible commands and arguments.
30+
31+
```shell
32+
python3 create_requirement_images.py --help
2633
```

Diff for: create_requirement_images.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
TEXT_COLOR = "#B0B0B0"
3939
HIDDEN_TEXT_COLOR = "#808080"
4040

41-
f = open("latest_bundle_data.json", "r")
42-
bundle_data = json.load(f)
43-
f.close()
41+
with open("latest_bundle_data.json", "r", encoding="utf-8") as f:
42+
bundle_data = json.load(f)
4443

4544
f = open("latest_community_bundle_data.json", "r")
4645
community_bundle_data = json.load(f)
@@ -432,14 +431,16 @@ def make_sd_dir(position):
432431
PADDING + (LINE_SPACING * (7 + project_files_count)),
433432
)
434433
make_libraries(final_list_to_render, _libraries_position)
434+
435435
_sd_dir_position = (
436436
76,
437437
PADDING
438-
+ (LINE_SPACING * (7 + project_files_count + len(final_list_to_render))),
438+
+ (LINE_SPACING * (7 + project_files_count + len(final_list_to_render)))
439+
+ (1 if context["added_settings_toml"] else 0) * LINE_SPACING,
439440
)
440441
make_sd_dir(_sd_dir_position)
441442

442-
img.save("generated_images/{}.png".format(image_name))
443+
img.save(f"generated_images/{image_name}.png")
443444

444445

445446
def generate_learn_requirement_image( # pylint: disable=invalid-name

Diff for: get_imports.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def ensure_latest_bundle(bundle_url, bundle_s3_url, bundle_tag_file, bundle_data
120120
COMMUNITY_BUNDLE_S3_URL,
121121
COMMUNITY_BUNDLE_TAG, COMMUNITY_BUNDLE_DATA)
122122

123-
with open(ADAFRUIT_BUNDLE_DATA, "r") as f:
123+
with open(ADAFRUIT_BUNDLE_DATA, "r", encoding="utf-8") as f:
124124
bundle_data = json.load(f)
125125

126126
with open(COMMUNITY_BUNDLE_DATA, "r") as f:
@@ -130,7 +130,7 @@ def ensure_latest_bundle(bundle_url, bundle_s3_url, bundle_tag_file, bundle_data
130130
def get_files_for_project(project_name):
131131
"""Get the set of files for a learn project"""
132132
found_files = set()
133-
project_dir = "{}/{}/".format(LEARN_GUIDE_REPO, project_name)
133+
project_dir = f"{LEARN_GUIDE_REPO}/{project_name}/"
134134

135135
full_tree = os.walk(project_dir)
136136
root_level = next(full_tree)
@@ -160,11 +160,11 @@ def get_libs_for_project(project_name):
160160
"""Get the set of libraries for a learn project"""
161161
found_libs = set()
162162
found_imports = []
163-
project_dir = "{}{}/".format(LEARN_GUIDE_REPO, project_name)
163+
project_dir = f"{LEARN_GUIDE_REPO}{project_name}/"
164164
for file in os.listdir(project_dir):
165165
if file.endswith(".py"):
166166

167-
found_imports = findimports.find_imports("{}{}".format(project_dir, file))
167+
found_imports = findimports.find_imports(f"{project_dir}{file}")
168168

169169
for cur_import in found_imports:
170170
cur_lib = cur_import.name.split(".")[0]

0 commit comments

Comments
 (0)