Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gerion Entrup
brainzfs
Commits
fe7de14d
Commit
fe7de14d
authored
Nov 21, 2016
by
Gerion Entrup
Browse files
add parser.py
untested
parent
c1cc5baf
Changes
1
Hide whitespace changes
Inline
Side-by-side
settings/parser.py
0 → 100755
View file @
fe7de14d
import
configparser
def
convert
(
settings
,
opt
,
value
):
t
=
type
(
getattr
(
settings
,
opt
))
try
:
return
t
(
value
)
except
:
return
None
def
parse
(
path
,
settings
):
config
=
configparser
.
ConfigParser
()
config
.
read
(
path
)
root
=
'settings'
root
=
config
[
root
]
for
opt
,
value
in
settings
.
get_options
():
if
opt
in
root
:
v
=
convert
(
settings
,
opt
,
root
[
opt
])
if
v
is
not
None
and
settings
.
check_constr
(
opt
,
v
):
setattr
(
settings
,
opt
,
v
)
Write
Preview
Supports
Markdown
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