Updated process_files
This commit is contained in:
42
h2inc.py
42
h2inc.py
@@ -12,7 +12,6 @@ import h2inc_gui
|
||||
|
||||
tupline = []
|
||||
preproc = ()
|
||||
outfile = ''
|
||||
filelist = []
|
||||
folderlist = []
|
||||
cnt = 0
|
||||
@@ -25,7 +24,8 @@ def sourcedir_filecnt(sourcedir):
|
||||
for file in files:
|
||||
if file.lower().endswith('.h'):
|
||||
cnt += 1
|
||||
filelist += [file]
|
||||
filelist += [folderName+'/'+file]
|
||||
print(folderName+'/'+file)
|
||||
#print(filelist)
|
||||
return cnt
|
||||
|
||||
@@ -40,27 +40,35 @@ def sourcedir_foldercnt(sourcedir):
|
||||
tempf = [file for file in files if file.lower().endswith('.h')]
|
||||
if tempf:
|
||||
cnt = cnt+1
|
||||
print(folderName)
|
||||
#print(folderName)
|
||||
folderlist += [folderName]
|
||||
#print(folderlist)
|
||||
#print(len(folderlist))
|
||||
return cnt
|
||||
|
||||
def process_files(sourcedir, destdir):
|
||||
global folderlist
|
||||
#global folderlist
|
||||
global filelist
|
||||
global preproc
|
||||
outfile = ''
|
||||
cnt = 0
|
||||
for f in folderlist:
|
||||
folderlist[cnt] = str(f).replace(str(sourcedir.get()), str(destdir.get()))
|
||||
print(folderlist[cnt])
|
||||
if not os.path.exists(folderlist[cnt]):
|
||||
os.makedirs(folderlist[cnt])
|
||||
for f in filelist:
|
||||
inputfile = f
|
||||
filehandle = open(f, 'r')
|
||||
cnt += 1
|
||||
#WorkPath = os.path.dirname(sourcedir)
|
||||
#print(WorkPath)
|
||||
#incpath = destdir
|
||||
#print(incpath)
|
||||
|
||||
#pattern = '.h'
|
||||
#inputfile = 'gtkaboutdialog.h'
|
||||
#filehandle = open(WorkPath+'/'+inputfile, 'r')
|
||||
for lines in filehandle:
|
||||
preproc = preproc+tuple([parseline(lines)])
|
||||
filehandle.close()
|
||||
for elements in preproc:
|
||||
outfile = outfile+parseparsed(elements)
|
||||
outputfile = os.path.splitext(inputfile)[0]+'.inc'
|
||||
outputfile = str(outputfile).replace(str(sourcedir.get()), str(destdir.get()))
|
||||
#if not os.path.exists(filelist[cnt]):
|
||||
#try:
|
||||
#os.makedirs(output)
|
||||
#except OSError as exc: # Guard against race condition
|
||||
#if exc.errno != errno.EEXIST:
|
||||
#raise
|
||||
newfile = open(outputfile, "w")
|
||||
newfile.write(outfile)
|
||||
newfile.close()
|
||||
|
Reference in New Issue
Block a user