mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-03 13:47:18 +03:00
cli: Drop the dict() handling for parsedata
Require passing in a Class. Let's not complicate the cli machinery any more than it has to be
This commit is contained in:
parent
7ec4c48268
commit
766dcc4e67
@ -891,10 +891,8 @@ def _on_off_convert(key, val):
|
||||
|
||||
|
||||
def _set_attribute(obj, attr, val):
|
||||
if isinstance(obj, dict):
|
||||
obj[attr] = val
|
||||
else:
|
||||
exec("obj." + attr + " = val ") # pylint: disable=exec-used
|
||||
# pylint: disable=unused-argument
|
||||
exec("obj." + attr + " = val ") # pylint: disable=exec-used
|
||||
|
||||
|
||||
class _VirtCLIArgumentStatic(object):
|
||||
@ -1012,7 +1010,7 @@ class _VirtCLIArgument(object):
|
||||
inst, self.val, self, True)
|
||||
|
||||
try:
|
||||
if not isinstance(inst, dict) and self.attrname:
|
||||
if self.attrname:
|
||||
eval("inst." + self.attrname) # pylint: disable=eval-used
|
||||
except AttributeError:
|
||||
raise RuntimeError("programming error: obj=%s does not have "
|
||||
@ -1496,15 +1494,17 @@ class ParseLocation(VirtCLIParser):
|
||||
|
||||
|
||||
def parse_location(optstr):
|
||||
parsedata = collections.OrderedDict()
|
||||
class LocationData:
|
||||
def __init__(self):
|
||||
self.location = None
|
||||
self.kernel = None
|
||||
self.initrd = None
|
||||
parsedata = LocationData()
|
||||
if optstr:
|
||||
parser = ParseLocation(None, optstr)
|
||||
parser.parse(parsedata)
|
||||
|
||||
location = parsedata.get("location")
|
||||
kernel = parsedata.get("kernel")
|
||||
initrd = parsedata.get("initrd")
|
||||
return location, kernel, initrd
|
||||
return parsedata.location, parsedata.kernel, parsedata.initrd
|
||||
|
||||
|
||||
########################
|
||||
|
Loading…
x
Reference in New Issue
Block a user