Updated process_files
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,6 @@ import h2inc_gui
|
|||||||
|
|
||||||
tupline = []
|
tupline = []
|
||||||
preproc = ()
|
preproc = ()
|
||||||
outfile = ''
|
|
||||||
filelist = []
|
filelist = []
|
||||||
folderlist = []
|
folderlist = []
|
||||||
cnt = 0
|
cnt = 0
|
||||||
@@ -25,7 +24,8 @@ def sourcedir_filecnt(sourcedir):
|
|||||||
for file in files:
|
for file in files:
|
||||||
if file.lower().endswith('.h'):
|
if file.lower().endswith('.h'):
|
||||||
cnt += 1
|
cnt += 1
|
||||||
filelist += [file]
|
filelist += [folderName+'/'+file]
|
||||||
|
print(folderName+'/'+file)
|
||||||
#print(filelist)
|
#print(filelist)
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
@@ -40,27 +40,35 @@ def sourcedir_foldercnt(sourcedir):
|
|||||||
tempf = [file for file in files if file.lower().endswith('.h')]
|
tempf = [file for file in files if file.lower().endswith('.h')]
|
||||||
if tempf:
|
if tempf:
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
print(folderName)
|
#print(folderName)
|
||||||
folderlist += [folderName]
|
folderlist += [folderName]
|
||||||
#print(folderlist)
|
#print(folderlist)
|
||||||
#print(len(folderlist))
|
#print(len(folderlist))
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
def process_files(sourcedir, destdir):
|
def process_files(sourcedir, destdir):
|
||||||
global folderlist
|
#global folderlist
|
||||||
global filelist
|
global filelist
|
||||||
|
global preproc
|
||||||
|
outfile = ''
|
||||||
cnt = 0
|
cnt = 0
|
||||||
for f in folderlist:
|
for f in filelist:
|
||||||
folderlist[cnt] = str(f).replace(str(sourcedir.get()), str(destdir.get()))
|
inputfile = f
|
||||||
print(folderlist[cnt])
|
filehandle = open(f, 'r')
|
||||||
if not os.path.exists(folderlist[cnt]):
|
|
||||||
os.makedirs(folderlist[cnt])
|
|
||||||
cnt += 1
|
cnt += 1
|
||||||
#WorkPath = os.path.dirname(sourcedir)
|
for lines in filehandle:
|
||||||
#print(WorkPath)
|
preproc = preproc+tuple([parseline(lines)])
|
||||||
#incpath = destdir
|
filehandle.close()
|
||||||
#print(incpath)
|
for elements in preproc:
|
||||||
|
outfile = outfile+parseparsed(elements)
|
||||||
#pattern = '.h'
|
outputfile = os.path.splitext(inputfile)[0]+'.inc'
|
||||||
#inputfile = 'gtkaboutdialog.h'
|
outputfile = str(outputfile).replace(str(sourcedir.get()), str(destdir.get()))
|
||||||
#filehandle = open(WorkPath+'/'+inputfile, 'r')
|
#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