Add files via upload
Updated process_files
This commit is contained in:
20
h2inc.py
20
h2inc.py
@@ -25,7 +25,7 @@ def sourcedir_filecnt(sourcedir):
|
||||
if file.lower().endswith('.h'):
|
||||
cnt += 1
|
||||
filelist += [folderName+'/'+file]
|
||||
print(folderName+'/'+file)
|
||||
print(folderName+'/'+file)
|
||||
#print(filelist)
|
||||
return cnt
|
||||
|
||||
@@ -55,20 +55,24 @@ def process_files(sourcedir, destdir):
|
||||
for f in filelist:
|
||||
inputfile = f
|
||||
filehandle = open(f, 'r')
|
||||
cnt += 1
|
||||
#cnt += 1
|
||||
print(os.path.basename(f))
|
||||
for lines in filehandle:
|
||||
print(lines)
|
||||
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
|
||||
print(outputfile)
|
||||
if not os.path.exists(os.path.dirname(outputfile)):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(outputfile))
|
||||
except OSError as exc: # Guard against race condition
|
||||
if exc.errno != errno.EEXIST:
|
||||
raise
|
||||
newfile = open(outputfile, "w")
|
||||
newfile.write(outfile)
|
||||
newfile.close()
|
||||
cnt += 1
|
||||
|
Reference in New Issue
Block a user