Did some minor corrections.
This commit is contained in:
@@ -59,7 +59,7 @@ class H2INC:
|
|||||||
self.tupline = []
|
self.tupline = []
|
||||||
self.tupfile = []
|
self.tupfile = []
|
||||||
|
|
||||||
def srcfilecnt(self.sourcedir):
|
def srcfilecnt(self, sourcedir):
|
||||||
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
|
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
|
||||||
for folderName, subfolders, files in os.walk(self.sourcedir):
|
for folderName, subfolders, files in os.walk(self.sourcedir):
|
||||||
for file in files:
|
for file in files:
|
||||||
@@ -71,12 +71,12 @@ class H2INC:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def srcfoldercnt(self.sourcedir):
|
def srcfoldercnt(self, sourcedir):
|
||||||
### Return the number of folders, if it contains '*.h' files, in sourcedir - including subdirectories ###
|
### Return the number of folders, if it contains '*.h' files, in sourcedir - including subdirectories ###
|
||||||
for folderName, subfolders, files in os.walk(self.sourcedir):
|
for folderName, subfolders, files in os.walk(self.sourcedir):
|
||||||
if subfolders:
|
if subfolders:
|
||||||
for subfolder in subfolders:
|
for subfolder in subfolders:
|
||||||
sourcedir_foldercnt(subfolder)
|
self.foldercnt(subfolder)
|
||||||
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:
|
||||||
self.foldercnt = self.foldercnt+1
|
self.foldercnt = self.foldercnt+1
|
||||||
@@ -86,7 +86,7 @@ class H2INC:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def read_file(fn):
|
def read_file(self, fn):
|
||||||
outfile = ''
|
outfile = ''
|
||||||
inputfile = fn
|
inputfile = fn
|
||||||
encodings = ['utf-8', 'latin-1', 'windows-1250', 'windows-1252', 'ascii',
|
encodings = ['utf-8', 'latin-1', 'windows-1250', 'windows-1252', 'ascii',
|
||||||
@@ -107,7 +107,7 @@ class H2INC:
|
|||||||
'utf-32-le', 'utf-16', 'utf-16-be', 'utf-16-le', 'utf-7', 'utf-8-sig']
|
'utf-32-le', 'utf-16', 'utf-16-be', 'utf-16-le', 'utf-7', 'utf-8-sig']
|
||||||
for e in encodings:
|
for e in encodings:
|
||||||
try:
|
try:
|
||||||
fh = io.open(fn, 'r', encoding=e)
|
fh = open(fn, 'r', encoding=e)
|
||||||
fh.readlines()
|
fh.readlines()
|
||||||
fh.seek(0)
|
fh.seek(0)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
@@ -122,10 +122,10 @@ class H2INC:
|
|||||||
tupfile.append(analysed_line)
|
tupfile.append(analysed_line)
|
||||||
fh.close()
|
fh.close()
|
||||||
outputfile = os.path.splitext(inputfile)[0]+'.inc'
|
outputfile = os.path.splitext(inputfile)[0]+'.inc'
|
||||||
outputfile = str(outputfile).replace(sourcedir, destdir)
|
outputfile = str(outputfile).replace(self.sourcedir, self.destdir)
|
||||||
write_file(outputfile,outfile)
|
self.write_file(outputfile,outfile)
|
||||||
|
|
||||||
def write_file(fn, data):
|
def write_file(self, fn, data):
|
||||||
if not os.path.exists(os.path.dirname(fn)):
|
if not os.path.exists(os.path.dirname(fn)):
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(fn))
|
os.makedirs(os.path.dirname(fn))
|
||||||
@@ -138,9 +138,9 @@ class H2INC:
|
|||||||
|
|
||||||
def analyzer(self, ln):
|
def analyzer(self, ln):
|
||||||
word = [w for w in ln.split()]
|
word = [w for w in ln.split()]
|
||||||
for w in word:
|
for w in word:
|
||||||
if w in hdr_keywords:
|
if w in hdr_keywords:
|
||||||
v=hdr_keywords[w]
|
v=hdr_keywords[w]
|
||||||
self.tupline.append(v)
|
self.tupline.append(v)
|
||||||
self.tupline.append(w)
|
self.tupline.append(w)
|
||||||
return tupline
|
return tupline
|
||||||
|
|||||||
Reference in New Issue
Block a user