Refactoring of function get_netbeans_file_list(file_list) to have a clearer code

pull/5532/head
Clemens Mandl 2017-11-28 07:42:13 +01:00
parent 61461bcc43
commit 52839aaa91
1 changed files with 6 additions and 11 deletions

View File

@ -309,7 +309,8 @@ class GNUARMNetbeans(Exporter):
output = [] output = []
prev_dir = '' prev_dir = ''
folder_count = 1 folder_count = 1
for idx, item in enumerate(file_list): dir_depth = 0
for item in (file_list):
cur_dir = os.path.dirname(item) cur_dir = os.path.dirname(item)
dir_temp = os.path.normpath(cur_dir) dir_temp = os.path.normpath(cur_dir)
prev_dir_temp = os.path.normpath(prev_dir) prev_dir_temp = os.path.normpath(prev_dir)
@ -317,10 +318,6 @@ class GNUARMNetbeans(Exporter):
prev_dir_list = prev_dir_temp.split(os.sep) prev_dir_list = prev_dir_temp.split(os.sep)
dir_depth = len(dir_list) dir_depth = len(dir_list)
# print 'PREV_DIR: ' + str(prev_dir_list)
# print 'CURR_DIR: ' + str(dir_list)
# Current File is in Directory: Compare the given dir with previous Dir # Current File is in Directory: Compare the given dir with previous Dir
if cur_dir and prev_dir != cur_dir: if cur_dir and prev_dir != cur_dir:
# evaluate all matched items (from current and previous list) # evaluate all matched items (from current and previous list)
@ -332,8 +329,6 @@ class GNUARMNetbeans(Exporter):
# calculate difference between matched and length # calculate difference between matched and length
diff = dir_depth - len(matched) diff = dir_depth - len(matched)
# print 'MATCHED: ' + str(matched)
# if previous dir was not root # if previous dir was not root
if prev_dir != '': if prev_dir != '':
# if the elements count is not equal we calculate the difference # if the elements count is not equal we calculate the difference
@ -364,10 +359,10 @@ class GNUARMNetbeans(Exporter):
# Save the Current Dir # Save the Current Dir
prev_dir = cur_dir prev_dir = cur_dir
output.append('<itemPath>' + str(item) + '</itemPath>') output.append('<itemPath>' + str(item) + '</itemPath>')
# if last iteration close all open tags
if idx == len(file_list) - 1 and cur_dir != '': if cur_dir != '':
for i in range(0, len(dir_list)): # close all open tags
output.append('</logicalFolder>') output.append('</logicalFolder>' * dir_depth)
return output return output