Skip to content

Commit 52839aa

Browse files
author
Clemens Mandl
committed
Refactoring of function get_netbeans_file_list(file_list) to have a clearer code
1 parent 61461bc commit 52839aa

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

tools/export/nb/__init__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,15 @@ def get_netbeans_file_list(file_list):
309309
output = []
310310
prev_dir = ''
311311
folder_count = 1
312-
for idx, item in enumerate(file_list):
312+
dir_depth = 0
313+
for item in (file_list):
313314
cur_dir = os.path.dirname(item)
314315
dir_temp = os.path.normpath(cur_dir)
315316
prev_dir_temp = os.path.normpath(prev_dir)
316317
dir_list = dir_temp.split(os.sep)
317318
prev_dir_list = prev_dir_temp.split(os.sep)
318319
dir_depth = len(dir_list)
319320

320-
# print 'PREV_DIR: ' + str(prev_dir_list)
321-
322-
# print 'CURR_DIR: ' + str(dir_list)
323-
324321
# Current File is in Directory: Compare the given dir with previous Dir
325322
if cur_dir and prev_dir != cur_dir:
326323
# evaluate all matched items (from current and previous list)
@@ -332,8 +329,6 @@ def get_netbeans_file_list(file_list):
332329
# calculate difference between matched and length
333330
diff = dir_depth - len(matched)
334331

335-
# print 'MATCHED: ' + str(matched)
336-
337332
# if previous dir was not root
338333
if prev_dir != '':
339334
# if the elements count is not equal we calculate the difference
@@ -364,10 +359,10 @@ def get_netbeans_file_list(file_list):
364359
# Save the Current Dir
365360
prev_dir = cur_dir
366361
output.append('<itemPath>' + str(item) + '</itemPath>')
367-
# if last iteration close all open tags
368-
if idx == len(file_list) - 1 and cur_dir != '':
369-
for i in range(0, len(dir_list)):
370-
output.append('</logicalFolder>')
362+
363+
if cur_dir != '':
364+
# close all open tags
365+
output.append('</logicalFolder>' * dir_depth)
371366

372367
return output
373368

0 commit comments

Comments
 (0)