From 993195fe22ef79ce4f6a97d203a991810d14d138 Mon Sep 17 00:00:00 2001 From: Lerking <33354709+Lerking@users.noreply.github.com> Date: Mon, 12 Feb 2018 07:27:36 +0100 Subject: [PATCH] Add files via upload Updated process_files --- h2inc.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/h2inc.py b/h2inc.py index 02d6b2a..760f4ce 100644 --- a/h2inc.py +++ b/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