Skip to content

Commit e45833e

Browse files
authored
Merge pull request #10 from FoamyGuy/examples_with_directories
fix image for library examples that contain directories.
2 parents 64c88a1 + 407b798 commit e45833e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

create_requirement_images.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def asset_path(asset_name):
7474
"pcf": file_font_icon,
7575
"bdf": file_font_icon,
7676
"json": file_icon,
77+
"license": file_empty_icon,
7778
}
7879

7980
# If this is not done, the images fail to load in the subprocesses.

get_imports.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,30 @@ def get_files_for_example(example_path):
158158
"""Get the set of files for a library example"""
159159
found_files = set(("code.py",))
160160
example_dir = os.path.dirname(example_path)
161-
for file in os.listdir(example_dir):
161+
162+
full_tree = os.walk(example_dir)
163+
root_level = next(full_tree)
164+
165+
for file in root_level[2]:
162166
if "." in file:
163167
cur_extension = file.split(".")[-1]
164168
if cur_extension in SHOWN_FILETYPES_EXAMPLE:
165169
# print(file)
166170
found_files.add(file)
167-
else:
168-
# add dir
169-
found_files.add(file)
171+
172+
for _dir in root_level[1]:
173+
dir_tuple = (_dir, tuple())
174+
for cur_tuple in os.walk(example_dir):
175+
if cur_tuple[0].split("/")[-1] == _dir:
176+
for _sub_dir in cur_tuple[1]:
177+
dir_tuple = (dir_tuple[0], dir_tuple[1] + (_sub_dir,))
178+
for _sub_file in cur_tuple[2]:
179+
dir_tuple = (dir_tuple[0], dir_tuple[1] + (_sub_file,))
180+
181+
# e.g. ("dir_name", ("file_1.txt", "file_2.txt"))
182+
183+
if ".circuitpython.skip-screenshot" not in dir_tuple[1]:
184+
found_files.add(dir_tuple)
170185
return found_files
171186

172187

@@ -201,7 +216,7 @@ def get_learn_guide_cp_projects():
201216
# Skip files in this folder, but handle sub-folders
202217
if ".circuitpython.skip-screenshot-here" in filenames:
203218
continue
204-
# Do not reurse, but handle files in this folder
219+
# Do not recurse, but handle files in this folder
205220
if ".circuitpython.skip-screenshot-sub" in filenames:
206221
del dirnames[:]
207222

0 commit comments

Comments
 (0)