|
17 | 17 | HIDDEN_TEXT_COLOR = "#808080"
|
18 | 18 |
|
19 | 19 | SHOWN_FILETYPES = ["py", "mpy", "bmp", "pcf", "bdf", "wav", "mp3", "json", "txt"]
|
20 |
| -""" |
21 |
| -libraries_to_render = ['adafruit_bitmap_font', |
22 |
| - 'adafruit_bus_device', |
23 |
| - 'adafruit_display_shapes', |
24 |
| - 'adafruit_display_text', |
25 |
| - 'adafruit_esp32spi', |
26 |
| - 'adafruit_hashlib', |
27 |
| - 'adafruit_imageload', |
28 |
| - 'adafruit_io', |
29 |
| - 'adafruit_progressbar', |
30 |
| - 'adafruit_pyportal', |
31 |
| - 'adafruit_binascii', |
32 |
| - 'adafruit_button', |
33 |
| - 'adafruit_ntp', |
34 |
| - 'adafruit_requests', |
35 |
| - 'adafruit_sdcard', |
36 |
| - 'adafruit_touchscreen', |
37 |
| - 'neopixel', |
38 |
| - 'simpleio' |
39 |
| - ] |
40 |
| - """ |
| 20 | + |
| 21 | + |
| 22 | + |
41 | 23 |
|
42 | 24 | f = open("adafruit-circuitpython-bundle-20210423.json", "r")
|
43 | 25 | bundle_data = json.load(f)
|
|
54 | 36 | file_empty_icon = Image.open('img/file_empty.png')
|
55 | 37 | file_empty_hidden_icon = Image.open('img/file_empty_hidden.png')
|
56 | 38 |
|
| 39 | +file_image_icon = Image.open('img/file_image.png') |
| 40 | +file_music_icon = Image.open('img/file_music.png') |
| 41 | +file_font_icon = Image.open('img/file_font.png') |
| 42 | + |
| 43 | +FILE_TYPE_ICON_MAP = { |
| 44 | + "py": file_icon, |
| 45 | + "mpy": file_icon, |
| 46 | + "txt": file_empty_icon, |
| 47 | + "bmp": file_image_icon, |
| 48 | + "wav": file_music_icon, |
| 49 | + "mp3": file_music_icon, |
| 50 | + "pcf": file_font_icon, |
| 51 | + "bdf": file_font_icon, |
| 52 | + "json": file_icon |
| 53 | +} |
| 54 | + |
57 | 55 |
|
58 | 56 | def generate_requirement_image(learn_guide_project):
|
59 | 57 | def make_line(requirement_name, position=(0, 0), icon=None, hidden=False, triangle_icon=None):
|
@@ -126,7 +124,15 @@ def make_header(position, learn_guide_project):
|
126 | 124 |
|
127 | 125 |
|
128 | 126 | for i, file in enumerate(project_files_to_draw):
|
129 |
| - make_line(file, (position[0] + INDENT_SIZE, position[1] + (LINE_SPACING * (6 + i )))) |
| 127 | + cur_file_extension = file.split(".")[-1] |
| 128 | + print("checking {}".format(cur_file_extension)) |
| 129 | + |
| 130 | + if cur_file_extension in FILE_TYPE_ICON_MAP: |
| 131 | + print("found icon for {}".format(cur_file_extension)) |
| 132 | + cur_file_icon = FILE_TYPE_ICON_MAP[cur_file_extension] |
| 133 | + else: |
| 134 | + cur_file_icon = file_empty_icon |
| 135 | + make_line(file, (position[0] + INDENT_SIZE, position[1] + (LINE_SPACING * (6 + i ))), icon=cur_file_icon) |
130 | 136 | rows_added += 1
|
131 | 137 |
|
132 | 138 | for i, file in enumerate(project_folders_to_draw):
|
|
0 commit comments