Skip to content

Commit

Permalink
change the way of find target file
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoMCU committed Jun 24, 2018
1 parent bd4fa0b commit 4b4442b
Showing 1 changed file with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions si4project_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,27 @@
import xml.etree.ElementTree as ET
from datetime import datetime

# 1、Find all .dep files and selete one
items = os.listdir()
sourcefilelist = []
for names in items:
if names.endswith(".dep"):
sourcefilelist.append(names)

# 1、Find .dep file
sourcefile = ''
for entry in os.scandir():
if entry.is_file():
if entry.name.endswith('.eww'):
for entry in os.scandir():
if entry.is_file():
if entry.name.endswith('.dep'):
sourcefile = entry.name
break
if '' == sourcefile:
print('Please build the project once')
input()
sys.exit(0)
elif entry.name.endswith('.uvproj') or entry.name.endswith('.uvprojx'):
sourcefile = ''
break

listsize = len(sourcefilelist)
if listsize > 1:
print("There are multiple .dep file:")
for index in range(0, listsize):
print("%d %s" % (index+1, sourcefilelist[index]))

print("Enter the index num to selete one:")
strin = input()
if strin.isdigit():
selnum = int(strin)
if (selnum < (listsize + 1)):
sourcefile = sourcefilelist[selnum - 1]
else:
print("Please restart the tool, the input shounld be a number")
sys.exit(0)

elif listsize == 1:
sourcefile = sourcefilelist[0]
else:
sourcefile = ''
if '' == sourcefile:
print('Can not find project file, enter any key to exit')
input()
sys.exit(0)

#2、parse the seleted dep file
Expand All @@ -58,11 +50,14 @@
output_tag = tag_cfg_list[selnum - 1].find('outputs')
else:
print("Please restart the tool, the input shounld be a number")
input()
sys.exit(0)

elif listsize == 1:
output_tag = tag_cfg_list[0].find('outputs')
else:
print("Please restart the tool, the input shounld be a number")
input()
sys.exit(0)

si4filelist = []
Expand All @@ -72,10 +67,7 @@
si4filelist.append(os.path.abspath(elem.text.replace('$PROJ_DIR$', os.getcwd()))+'\n')
elif elem.text.endswith('.h'):
si4filelist.append(os.path.abspath(elem.text.replace('$PROJ_DIR$', os.getcwd()))+'\n')
'''
elif elem.text.startswith('$TOOLKIT_DIR$'):
print(elem.text)
'''


#3、save the lists
outputfile = open(os.path.splitext(sourcefile)[0]+'.si4project_filelist.txt', 'w')
Expand Down

0 comments on commit 4b4442b

Please sign in to comment.