Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathExtractStrings.py
More file actions
Latest commit
62 lines (46 loc) · 1.57 KB
/
Copy pathExtractStrings.py
File metadata and controls
62 lines (46 loc) · 1.57 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
51
52
53
54
55
56
57
58
59
60
61
62
#This script extracts tag and attribute names from the given xsd file and generates C header or source
#declarations/definitions for the corresponding strings. These are expected to be pasted in to string_const.h
#or string_const.cpp.
importsys
defaddEntry( prefix, line, stringList ):
index=line.find( prefix )
if( index>0 ):
endIndex=line.find( "\"", index+len( prefix ) )
if( endIndex>0 ):
entry=line[index+len(prefix):endIndex]
if( stringList.count( entry ) ==0 ):
stringList.insert( 0, entry )
defprintEntry( entry, suffix, hdrMode ):
oLine=""
oLine+="const xmlChar * const "
oLine+=entry[0].upper()
foriinrange(1,len(entry)):
c=entry[i]
if( ( c.upper() ==c ) and ( entry[i+1].lower() ==entry[i+1] ) ):
oLine+="_"
oLine+=c.upper()
oLine+=suffix
if( hdrMode ):
oLine="extern "+oLine+";"
else:
if( len( oLine ) <56 ):
oLine=oLine.ljust( 56 )
oLine+="= (const xmlChar* const)\""+entry+"\";"
printoLine
defprocessFile( filename, hdrMode ):
rawFile=open( filename )
elements= []
attributes= []
forlineinrawFile:
line=line.rstrip()
addEntry( "xs:element name=\"", line, elements )
addEntry( "xs:attribute name=\"", line, attributes )
foreinelements[0:]:
printEntry( e, "_TAG", hdrMode )
print
print
forainattributes[0:]:
printEntry( a, "_ATTRIB", hdrMode )
print
rawFile.close()
processFile( sys.argv[1], sys.argv[2] =="True" )