don't use ast.literal_eval, just directly convert to the desired type
It's slow and unnecessary
This commit is contained in:
parent
565bdf8549
commit
14b3acec24
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
'''Base classes for managed objects'''
|
'''Base classes for managed objects'''
|
||||||
|
|
||||||
import ast
|
|
||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
DEFAULT = object()
|
DEFAULT = object()
|
||||||
@ -151,7 +150,7 @@ class PropertyHolder(object):
|
|||||||
(default, _value) = property_str.split(b' ', 1)
|
(default, _value) = property_str.split(b' ', 1)
|
||||||
assert default.startswith(b'default=')
|
assert default.startswith(b'default=')
|
||||||
is_default_str = default.split(b'=')[1]
|
is_default_str = default.split(b'=')[1]
|
||||||
is_default = ast.literal_eval(is_default_str.decode('ascii'))
|
is_default = is_default_str.decode('ascii') == "True"
|
||||||
assert isinstance(is_default, bool)
|
assert isinstance(is_default, bool)
|
||||||
return is_default
|
return is_default
|
||||||
|
|
||||||
@ -196,11 +195,11 @@ class PropertyHolder(object):
|
|||||||
elif prop_type == 'bool':
|
elif prop_type == 'bool':
|
||||||
if value == '':
|
if value == '':
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
return ast.literal_eval(value)
|
return value == "True"
|
||||||
elif prop_type == 'int':
|
elif prop_type == 'int':
|
||||||
if value == '':
|
if value == '':
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
return ast.literal_eval(value)
|
return int(value)
|
||||||
elif prop_type == 'vm':
|
elif prop_type == 'vm':
|
||||||
if value == '':
|
if value == '':
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user