Major updates regarding global variables
This commit is contained in:
+9
-14
@@ -9,27 +9,23 @@ import os
|
||||
import sys
|
||||
import io
|
||||
import time
|
||||
from h2inc_globals import destdir, defdest, filelist, folderlist, cnt, srcdir
|
||||
import globvar
|
||||
|
||||
def sourcedir_filecnt(sourcedir):
|
||||
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
|
||||
global cnt
|
||||
global filelist
|
||||
global srcdir
|
||||
srcdir = sourcedir
|
||||
globvar.srcdir = sourcedir
|
||||
for folderName, subfolders, files in os.walk(sourcedir):
|
||||
for file in files:
|
||||
if file.lower().endswith('.h'):
|
||||
cnt += 1
|
||||
filelist += [folderName + '/' + file]
|
||||
globvar.cnt += 1
|
||||
globvar.filelist += [folderName + '/' + file]
|
||||
print(folderName + '/' + file)
|
||||
# print(filelist)
|
||||
return cnt
|
||||
return globvar.cnt
|
||||
|
||||
def sourcedir_foldercnt(sourcedir):
|
||||
### Return the number of folders, if it contains '*.h' files, in sourcedir - including subdirectories ###
|
||||
cnt = 0
|
||||
global folderlist
|
||||
for folderName, subfolders, files in os.walk(sourcedir):
|
||||
if subfolders:
|
||||
for subfolder in subfolders:
|
||||
@@ -38,13 +34,12 @@ def sourcedir_foldercnt(sourcedir):
|
||||
if tempf:
|
||||
cnt = cnt + 1
|
||||
# print(folderName)
|
||||
folderlist += [folderName]
|
||||
globvar.folderlist += [folderName]
|
||||
# print(folderlist)
|
||||
# print(len(folderlist))
|
||||
return cnt
|
||||
|
||||
def process_file(data):
|
||||
global count
|
||||
outfile = ''
|
||||
inputfile = data
|
||||
encodings = ['utf-8', 'latin-1', 'windows-1250', 'windows-1252', 'ascii',
|
||||
@@ -78,9 +73,9 @@ def process_file(data):
|
||||
outfile = outfile + lines
|
||||
fh.close()
|
||||
outputfile = os.path.splitext(inputfile)[0] + '.inc'
|
||||
outputfile = str(outputfile).replace(srcdir, destdir)
|
||||
count += 1
|
||||
print(str(count)+'->'+outputfile)
|
||||
outputfile = str(outputfile).replace(globvar.srcdir, globvar.destdir)
|
||||
globvar.count += 1
|
||||
print(str(globvar.count)+'->'+outputfile)
|
||||
if not os.path.exists(os.path.dirname(outputfile)):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(outputfile))
|
||||
|
||||
Reference in New Issue
Block a user