@@ -86,6 +86,7 @@ def generate_requirement_image(
86
86
): # pylint: disable=too-many-statements
87
87
"""Generate a single requirement image"""
88
88
89
+
89
90
def make_line (
90
91
requirement_name , position = (0 , 0 ), icon = None , hidden = False , triangle_icon = None
91
92
): # pylint: disable=too-many-branches
@@ -192,14 +193,16 @@ def make_header(position, project_files):
192
193
# dynamic files from project dir in learn guide repo
193
194
rows_added = 0
194
195
project_files_to_draw = []
195
- project_folders_to_draw = []
196
+ project_folders_to_draw = {}
196
197
for cur_file in project_files :
197
- if "." in cur_file [- 5 :]:
198
- cur_extension = cur_file .split ("." )[- 1 ]
199
- if cur_extension in SHOWN_FILETYPES :
200
- project_files_to_draw .append (cur_file )
201
- else :
202
- project_folders_to_draw .append (cur_file )
198
+ if type (cur_file ) == str :
199
+ if "." in cur_file [- 5 :]:
200
+ cur_extension = cur_file .split ("." )[- 1 ]
201
+ if cur_extension in SHOWN_FILETYPES :
202
+ project_files_to_draw .append (cur_file )
203
+
204
+ elif type (cur_file ) == tuple :
205
+ project_folders_to_draw [cur_file [0 ]] = cur_file [1 ]
203
206
204
207
for i , file in enumerate (sorted (project_files_to_draw )):
205
208
cur_file_extension = file .split ("." )[- 1 ]
@@ -212,16 +215,41 @@ def make_header(position, project_files):
212
215
)
213
216
rows_added += 1
214
217
215
- for i , file in enumerate (sorted (project_folders_to_draw )):
218
+ extra_rows = 0
219
+ for i , file in enumerate (sorted (project_folders_to_draw .keys ())):
216
220
make_line (
217
221
file ,
218
222
(
219
223
position [0 ] + INDENT_SIZE * 2 ,
220
- position [1 ] + (LINE_SPACING * (6 + i + len (project_files_to_draw ))),
224
+ position [1 ] + (LINE_SPACING * (6 + i + len (project_files_to_draw ) + extra_rows )),
221
225
),
222
- triangle_icon = right_triangle ,
226
+ triangle_icon = down_triangle ,
223
227
)
224
228
rows_added += 1
229
+ if file == "midi" :
230
+ #print(project_folders_to_draw)
231
+ pass
232
+ extra_sub_file_space = 0
233
+ for j , sub_file in enumerate (sorted (project_folders_to_draw [file ])):
234
+ extra_rows += 1
235
+ cur_file_extension = sub_file .split ("." )[- 1 ]
236
+ cur_file_icon = FILE_TYPE_ICON_MAP .get (cur_file_extension , folder_icon )
237
+ triangle_icon = None
238
+ if cur_file_icon == folder_icon :
239
+ triangle_icon = right_triangle
240
+ make_line (
241
+ sub_file ,
242
+ (
243
+ position [0 ] + INDENT_SIZE * 3 ,
244
+ #position[1] + (LINE_SPACING * (6 + i + j + 1 + extra_sub_file_space
245
+ # + len(project_files_to_draw))),
246
+ position [1 ] + (LINE_SPACING * (6 + rows_added )),
247
+ ),
248
+ triangle_icon = triangle_icon ,
249
+ icon = cur_file_icon
250
+ )
251
+ rows_added += 1
252
+ extra_sub_file_space = extra_rows
225
253
226
254
make_line (
227
255
"lib" ,
@@ -281,6 +309,16 @@ def sort_libraries(libraries):
281
309
package_list , file_list = get_dependencies (libraries )
282
310
return sorted (package_list ) + sorted (file_list )
283
311
312
+ def count_files (files_list ):
313
+ _count = 0
314
+ for _file in files_list :
315
+ if type (_file ) == str :
316
+ _count += 1
317
+ elif type (_file ) == tuple :
318
+ _count += 1
319
+ _count += len (_file [1 ])
320
+ return _count
321
+
284
322
def make_libraries (libraries , position ):
285
323
286
324
for i , lib_name in enumerate (libraries ):
@@ -301,7 +339,7 @@ def make_libraries(libraries, position):
301
339
if "main.py" in project_files :
302
340
project_files .remove ("main.py" )
303
341
304
- project_files_count = len (project_files )
342
+ project_files_count = count_files (project_files )
305
343
306
344
image_height = (
307
345
PADDING * 2
0 commit comments