@@ -86,7 +86,6 @@ def generate_requirement_image(
8686): # pylint: disable=too-many-statements
8787 """Generate a single requirement image"""
8888
89-
9089 def make_line (
9190 requirement_name , position = (0 , 0 ), icon = None , hidden = False , triangle_icon = None
9291 ): # pylint: disable=too-many-branches
@@ -161,7 +160,11 @@ def make_line(
161160
162161 def make_header (position , project_files ):
163162 # 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+ )
165168 make_line (
166169 ".fseventsd" ,
167170 (position [0 ] + INDENT_SIZE * 2 , position [1 ] + (LINE_SPACING * 1 )),
@@ -195,13 +198,14 @@ def make_header(position, project_files):
195198 project_files_to_draw = []
196199 project_folders_to_draw = {}
197200 for cur_file in project_files :
198- if type (cur_file ) == str :
201+ # string for individual file
202+ if isinstance (cur_file , str ):
199203 if "." in cur_file [- 5 :]:
200204 cur_extension = cur_file .split ("." )[- 1 ]
201205 if cur_extension in SHOWN_FILETYPES :
202206 project_files_to_draw .append (cur_file )
203-
204- elif type (cur_file ) == tuple :
207+ # tuple for directory
208+ elif isinstance (cur_file , tuple ) :
205209 project_folders_to_draw [cur_file [0 ]] = cur_file [1 ]
206210
207211 for i , file in enumerate (sorted (project_files_to_draw )):
@@ -221,12 +225,15 @@ def make_header(position, project_files):
221225 file ,
222226 (
223227 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+ ),
225232 ),
226233 triangle_icon = down_triangle ,
227234 )
228235 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 ]):
230237 extra_rows += 1
231238 cur_file_extension = sub_file .split ("." )[- 1 ]
232239 cur_file_icon = FILE_TYPE_ICON_MAP .get (cur_file_extension , folder_icon )
@@ -236,13 +243,11 @@ def make_header(position, project_files):
236243 make_line (
237244 sub_file ,
238245 (
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 ,
242247 position [1 ] + (LINE_SPACING * (6 + rows_added )),
243248 ),
244249 triangle_icon = triangle_icon ,
245- icon = cur_file_icon
250+ icon = cur_file_icon ,
246251 )
247252 rows_added += 1
248253
@@ -307,9 +312,12 @@ def sort_libraries(libraries):
307312 def count_files (files_list ):
308313 _count = 0
309314 for _file in files_list :
310- if type (_file ) == str :
315+ # string for individual file
316+ if isinstance (_file , str ):
311317 _count += 1
312- elif type (_file ) == tuple :
318+
319+ # tuple for directory
320+ elif isinstance (_file , tuple ):
313321 _count += 1
314322 _count += len (_file [1 ])
315323 return _count
0 commit comments