@@ -86,7 +86,6 @@ def generate_requirement_image(
86
86
): # pylint: disable=too-many-statements
87
87
"""Generate a single requirement image"""
88
88
89
-
90
89
def make_line (
91
90
requirement_name , position = (0 , 0 ), icon = None , hidden = False , triangle_icon = None
92
91
): # pylint: disable=too-many-branches
@@ -161,7 +160,11 @@ def make_line(
161
160
162
161
def make_header (position , project_files ):
163
162
# Static files
164
- make_line ("CIRCUITPY" , (position [0 ] + INDENT_SIZE , position [1 ]), triangle_icon = down_triangle )
163
+ make_line (
164
+ "CIRCUITPY" ,
165
+ (position [0 ] + INDENT_SIZE , position [1 ]),
166
+ triangle_icon = down_triangle ,
167
+ )
165
168
make_line (
166
169
".fseventsd" ,
167
170
(position [0 ] + INDENT_SIZE * 2 , position [1 ] + (LINE_SPACING * 1 )),
@@ -195,13 +198,14 @@ def make_header(position, project_files):
195
198
project_files_to_draw = []
196
199
project_folders_to_draw = {}
197
200
for cur_file in project_files :
198
- if type (cur_file ) == str :
201
+ # string for individual file
202
+ if isinstance (cur_file , str ):
199
203
if "." in cur_file [- 5 :]:
200
204
cur_extension = cur_file .split ("." )[- 1 ]
201
205
if cur_extension in SHOWN_FILETYPES :
202
206
project_files_to_draw .append (cur_file )
203
-
204
- elif type (cur_file ) == tuple :
207
+ # tuple for directory
208
+ elif isinstance (cur_file , tuple ) :
205
209
project_folders_to_draw [cur_file [0 ]] = cur_file [1 ]
206
210
207
211
for i , file in enumerate (sorted (project_files_to_draw )):
@@ -221,12 +225,15 @@ def make_header(position, project_files):
221
225
file ,
222
226
(
223
227
position [0 ] + INDENT_SIZE * 2 ,
224
- position [1 ] + (LINE_SPACING * (6 + i + len (project_files_to_draw ) + extra_rows )),
228
+ position [1 ]
229
+ + (
230
+ LINE_SPACING * (6 + i + len (project_files_to_draw ) + extra_rows )
231
+ ),
225
232
),
226
233
triangle_icon = down_triangle ,
227
234
)
228
235
rows_added += 1
229
- for j , sub_file in enumerate ( sorted (project_folders_to_draw [file ]) ):
236
+ for sub_file in sorted (project_folders_to_draw [file ]):
230
237
extra_rows += 1
231
238
cur_file_extension = sub_file .split ("." )[- 1 ]
232
239
cur_file_icon = FILE_TYPE_ICON_MAP .get (cur_file_extension , folder_icon )
@@ -236,13 +243,11 @@ def make_header(position, project_files):
236
243
make_line (
237
244
sub_file ,
238
245
(
239
- position [0 ] + INDENT_SIZE * 3 ,
240
- #position[1] + (LINE_SPACING * (6 + i + j + 1 + extra_sub_file_space
241
- # + len(project_files_to_draw))),
246
+ position [0 ] + INDENT_SIZE * 3 ,
242
247
position [1 ] + (LINE_SPACING * (6 + rows_added )),
243
248
),
244
249
triangle_icon = triangle_icon ,
245
- icon = cur_file_icon
250
+ icon = cur_file_icon ,
246
251
)
247
252
rows_added += 1
248
253
@@ -307,9 +312,12 @@ def sort_libraries(libraries):
307
312
def count_files (files_list ):
308
313
_count = 0
309
314
for _file in files_list :
310
- if type (_file ) == str :
315
+ # string for individual file
316
+ if isinstance (_file , str ):
311
317
_count += 1
312
- elif type (_file ) == tuple :
318
+
319
+ # tuple for directory
320
+ elif isinstance (_file , tuple ):
313
321
_count += 1
314
322
_count += len (_file [1 ])
315
323
return _count
0 commit comments