Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doxverilog
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
doxverilog
Commits
4ed8db1d
Commit
4ed8db1d
authored
May 21, 2013
by
Philipp Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configgen.py: Tabify
Some python installation bork on inconsistent tab/spaces indents
parent
eb193634
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
75 deletions
+75
-75
configgen.py
src/configgen.py
+75
-75
No files found.
src/configgen.py
View file @
4ed8db1d
...
@@ -16,91 +16,91 @@ import sys
...
@@ -16,91 +16,91 @@ import sys
from
xml.dom
import
minidom
,
Node
from
xml.dom
import
minidom
,
Node
def
addValues
(
var
,
node
):
def
addValues
(
var
,
node
):
for
n
in
node
.
childNodes
:
for
n
in
node
.
childNodes
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
name
=
n
.
getAttribute
(
'name'
);
name
=
n
.
getAttribute
(
'name'
);
print
"
%
s->addValue(
\"
%
s
\"
);"
%
(
var
,
name
)
print
"
%
s->addValue(
\"
%
s
\"
);"
%
(
var
,
name
)
def
parseOption
(
node
):
def
parseOption
(
node
):
name
=
node
.
getAttribute
(
'id'
)
name
=
node
.
getAttribute
(
'id'
)
type
=
node
.
getAttribute
(
'type'
)
type
=
node
.
getAttribute
(
'type'
)
format
=
node
.
getAttribute
(
'format'
)
format
=
node
.
getAttribute
(
'format'
)
doc
=
node
.
getAttribute
(
'docs'
)
doc
=
node
.
getAttribute
(
'docs'
)
defval
=
node
.
getAttribute
(
'defval'
)
defval
=
node
.
getAttribute
(
'defval'
)
adefval
=
node
.
getAttribute
(
'altdefval'
)
adefval
=
node
.
getAttribute
(
'altdefval'
)
depends
=
node
.
getAttribute
(
'depends'
)
depends
=
node
.
getAttribute
(
'depends'
)
setting
=
node
.
getAttribute
(
'setting'
)
setting
=
node
.
getAttribute
(
'setting'
)
# replace \ by \\, replace " by \", and ' ' by a newline with end string and start string at next line
# replace \ by \\, replace " by \", and ' ' by a newline with end string and start string at next line
docC
=
doc
.
strip
()
.
replace
(
'
\\
'
,
'
\\\\
'
)
.
replace
(
'"'
,
'
\\
"'
)
.
replace
(
' '
,
'
\\
n"
\n
"'
)
docC
=
doc
.
strip
()
.
replace
(
'
\\
'
,
'
\\\\
'
)
.
replace
(
'"'
,
'
\\
"'
)
.
replace
(
' '
,
'
\\
n"
\n
"'
)
if
len
(
setting
)
>
0
:
if
len
(
setting
)
>
0
:
print
"#if
%
s"
%
(
setting
)
print
"#if
%
s"
%
(
setting
)
print
"
//----"
print
"
//----"
if
type
==
'bool'
:
if
type
==
'bool'
:
if
len
(
adefval
)
>
0
:
if
len
(
adefval
)
>
0
:
enabled
=
adefval
enabled
=
adefval
elif
defval
==
'1'
:
elif
defval
==
'1'
:
enabled
=
"TRUE"
enabled
=
"TRUE"
else
:
else
:
enabled
=
"FALSE"
enabled
=
"FALSE"
print
"
cb = cfg->addBool("
print
"
cb = cfg->addBool("
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
%
s"
%
(
enabled
)
print
"
%
s"
%
(
enabled
)
print
"
);"
print
"
);"
if
depends
!=
''
:
if
depends
!=
''
:
print
"
cb->addDependency(
\"
%
s
\"
);"
%
(
depends
)
print
"
cb->addDependency(
\"
%
s
\"
);"
%
(
depends
)
elif
type
==
'string'
:
elif
type
==
'string'
:
print
"
cs = cfg->addString("
print
"
cs = cfg->addString("
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
"
%
(
docC
)
print
"
\"
%
s
\"
"
%
(
docC
)
print
"
);"
print
"
);"
if
defval
!=
''
:
if
defval
!=
''
:
print
"
cs->setDefaultValue(
\"
%
s
\"
);"
%
(
defval
)
print
"
cs->setDefaultValue(
\"
%
s
\"
);"
%
(
defval
)
if
format
==
'file'
:
if
format
==
'file'
:
print
"
cs->setWidgetType(ConfigString::File);"
print
"
cs->setWidgetType(ConfigString::File);"
elif
format
==
'dir'
:
elif
format
==
'dir'
:
print
"
cs->setWidgetType(ConfigString::Dir);"
print
"
cs->setWidgetType(ConfigString::Dir);"
if
depends
!=
''
:
if
depends
!=
''
:
print
"
cs->addDependency(
\"
%
s
\"
);"
%
(
depends
)
print
"
cs->addDependency(
\"
%
s
\"
);"
%
(
depends
)
elif
type
==
'enum'
:
elif
type
==
'enum'
:
print
"
ce = cfg->addEnum("
print
"
ce = cfg->addEnum("
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
\"
%
s
\"
"
%
(
defval
)
print
"
\"
%
s
\"
"
%
(
defval
)
print
"
);"
print
"
);"
addValues
(
"ce"
,
node
)
addValues
(
"ce"
,
node
)
if
depends
!=
''
:
if
depends
!=
''
:
print
"
ce->addDependency(
\"
%
s
\"
);"
%
(
depends
)
print
"
ce->addDependency(
\"
%
s
\"
);"
%
(
depends
)
elif
type
==
'int'
:
elif
type
==
'int'
:
minval
=
node
.
getAttribute
(
'minval'
)
minval
=
node
.
getAttribute
(
'minval'
)
maxval
=
node
.
getAttribute
(
'maxval'
)
maxval
=
node
.
getAttribute
(
'maxval'
)
print
"
ci = cfg->addInt("
print
"
ci = cfg->addInt("
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
\"
%
s
\"
,"
%
(
docC
)
print
"
%
s,
%
s,
%
s"
%
(
minval
,
maxval
,
defval
)
print
"
%
s,
%
s,
%
s"
%
(
minval
,
maxval
,
defval
)
print
"
);"
print
"
);"
if
depends
!=
''
:
if
depends
!=
''
:
print
"
ci->addDependency(
\"
%
s
\"
);"
%
(
depends
)
print
"
ci->addDependency(
\"
%
s
\"
);"
%
(
depends
)
elif
type
==
'list'
:
elif
type
==
'list'
:
print
"
cl = cfg->addList("
print
"
cl = cfg->addList("
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
,"
%
(
name
)
print
"
\"
%
s
\"
"
%
(
docC
)
print
"
\"
%
s
\"
"
%
(
docC
)
print
"
);"
print
"
);"
addValues
(
"cl"
,
node
)
addValues
(
"cl"
,
node
)
if
depends
!=
''
:
if
depends
!=
''
:
print
"
cl->addDependency(
\"
%
s
\"
);"
%
(
depends
)
print
"
cl->addDependency(
\"
%
s
\"
);"
%
(
depends
)
if
format
==
'file'
:
if
format
==
'file'
:
print
"
cl->setWidgetType(ConfigList::File);"
print
"
cl->setWidgetType(ConfigList::File);"
elif
format
==
'dir'
:
elif
format
==
'dir'
:
print
"
cl->setWidgetType(ConfigList::Dir);"
print
"
cl->setWidgetType(ConfigList::Dir);"
elif
format
==
'filedir'
:
elif
format
==
'filedir'
:
print
"
cl->setWidgetType(ConfigList::FileAndDir);"
print
"
cl->setWidgetType(ConfigList::FileAndDir);"
elif
type
==
'obsolete'
:
elif
type
==
'obsolete'
:
print
"
cfg->addObsolete(
\"
%
s
\"
);"
%
(
name
)
print
"
cfg->addObsolete(
\"
%
s
\"
);"
%
(
name
)
if
len
(
setting
)
>
0
:
if
len
(
setting
)
>
0
:
print
"#else"
print
"#else"
print
"
cfg->addDisabled(
\"
%
s
\"
);"
%
(
name
)
print
"
cfg->addDisabled(
\"
%
s
\"
);"
%
(
name
)
print
"#endif"
print
"#endif"
...
@@ -108,11 +108,11 @@ def parseOption(node):
...
@@ -108,11 +108,11 @@ def parseOption(node):
def
parseGroups
(
node
):
def
parseGroups
(
node
):
name
=
node
.
getAttribute
(
'name'
)
name
=
node
.
getAttribute
(
'name'
)
doc
=
node
.
getAttribute
(
'docs'
)
doc
=
node
.
getAttribute
(
'docs'
)
print
"
//---------------------------------------------------------------------------"
;
print
"
//---------------------------------------------------------------------------"
;
print
"
cfg->addInfo(
\"
%
s
\"
,
\"
%
s
\"
);"
%
(
name
,
doc
)
print
"
cfg->addInfo(
\"
%
s
\"
,
\"
%
s
\"
);"
%
(
name
,
doc
)
print
"
//---------------------------------------------------------------------------"
;
print
"
//---------------------------------------------------------------------------"
;
print
print
for
n
in
node
.
childNodes
:
for
n
in
node
.
childNodes
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
parseOption
(
n
)
parseOption
(
n
)
...
@@ -120,28 +120,28 @@ def parseGroups(node):
...
@@ -120,28 +120,28 @@ def parseGroups(node):
def
main
():
def
main
():
doc
=
xml
.
dom
.
minidom
.
parse
(
sys
.
argv
[
1
])
doc
=
xml
.
dom
.
minidom
.
parse
(
sys
.
argv
[
1
])
elem
=
doc
.
documentElement
elem
=
doc
.
documentElement
print
"/* WARNING: This file is generated!"
print
"/* WARNING: This file is generated!"
print
" * Do not edit this file, but edit config.xml instead and run"
print
" * Do not edit this file, but edit config.xml instead and run"
print
" * python configgen.py to regenerate this file!"
print
" * python configgen.py to regenerate this file!"
print
" */"
print
" */"
print
""
print
""
print
"#include
\"
configoptions.h
\"
"
print
"#include
\"
configoptions.h
\"
"
print
"#include
\"
config.h
\"
"
print
"#include
\"
config.h
\"
"
print
"#include
\"
portable.h
\"
"
print
"#include
\"
portable.h
\"
"
print
"#include
\"
settings.h
\"
"
print
"#include
\"
settings.h
\"
"
print
""
print
""
print
"void addConfigOptions(Config *cfg)"
print
"void addConfigOptions(Config *cfg)"
print
"{"
print
"{"
print
"
ConfigString *cs;"
print
"
ConfigString *cs;"
print
"
ConfigEnum *ce;"
print
"
ConfigEnum *ce;"
print
"
ConfigList *cl;"
print
"
ConfigList *cl;"
print
"
ConfigInt *ci;"
print
"
ConfigInt *ci;"
print
"
ConfigBool *cb;"
print
"
ConfigBool *cb;"
print
""
print
""
for
n
in
elem
.
childNodes
:
for
n
in
elem
.
childNodes
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
if
n
.
nodeType
==
Node
.
ELEMENT_NODE
:
parseGroups
(
n
)
parseGroups
(
n
)
print
"}"
print
"}"
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment