-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeaderFileParserBase.py
More file actions
50 lines (40 loc) · 1.7 KB
/
HeaderFileParserBase.py
File metadata and controls
50 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
import sys
class HeaderParserBase(object):
inFile = ''
savePath = ''
cSaveFile = '' # file to save const to
sSaveFile = '' # file to save structs to
eSaveFile = '' # file to save enums to
mSaveFile = '' # file to save methods to
wSaveFile = '' # file to save wrapper methods to
def __init__(self, inFile, savePath):
if not self.checkFile(inFile):
print "Error: No file provided, script aborted!"
sys.exit()
if not self.checkFile(savePath):
savePath = inFile[0:inFile.rfind('/')] if inFile.find('/') > -1 else ""
print "Warning: No save path provided. Using: {0}/".format(savePath)
self.inFile = inFile
self.savePath = savePath
self.setSaveFiles()
def checkFile(self, fileToCheck):
if self.hasValue(fileToCheck):
indx = fileToCheck.find(".")
if indx > 0 and indx < len(fileToCheck) - 1:
return True
return False
def checkPath(self, pathToCheck):
return self.hasValue(pathToCheck)
def hasValue(self, itemToCheck):
if itemToCheck == "" or itemToCheck == None:
return False
else:
return True
def setSaveFiles(self):
f = self.inFile[self.inFile.rfind('/'):].split(".")[0]
self.mSaveFile = "{0}{1}_methods.cs".format(self.savePath,f)
self.eSaveFile = "{0}{1}_enums.cs".format(self.savePath,f)
self.sSaveFile = "{0}{1}_structs.cs".format(self.savePath,f)
self.cSaveFile = "{0}{1}_consts.cs".format(self.savePath,f)
self.wSaveFile = "{0}{1}_wrap_methods.cs".format(self.savePath, f)