générifier au maxium handle_*

This commit is contained in:
Jephté Clain 2017-06-18 08:53:34 +04:00
parent 41f4e724bd
commit f0de1213f6
1 changed files with 45 additions and 45 deletions

View File

@ -642,29 +642,29 @@ class Parser(object):
# traiter les hôtes
for nvs in nvss:
name, values = split_nlist(nvs)
for host in values:
for value in values:
dir = None
if host:
if '/' in host:
dir, host = path.split(path.abspath(path.expanduser(host)))
host = self.__fix_host(host)
if value:
if '/' in value:
dir, value = path.split(path.abspath(path.expanduser(value)))
value = self.__fix_host(value)
if name:
o = self.db.get_object(otype, name)
if host: o.add_value(host)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
self.add_group(otype, name)
else:
id = HostObject.genid(host)
id = HostObject.genid(value)
o = self.db.get_object(otype, id)
o.add_value(host)
o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
self.add_group(otype, id)
ib = HostObject.genib(id)
o = self.db.get_object(otype, ib)
o.add_value(host)
o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
self.add_group(otype, ib)
@ -721,29 +721,29 @@ class Parser(object):
# traiter les modules
for nvs in nvss:
name, values = split_nlist(nvs)
for module in values:
for value in values:
dir = None
modulep = None
if module:
if '/' in module:
dir, module = path.split(path.abspath(path.expanduser(module)))
module = self.__fix_module(module)
valuep = None
if value:
if '/' in value:
dir, value = path.split(path.abspath(path.expanduser(value)))
value = self.__fix_module(value)
if dir is not None:
modulep = path.join(dir, module)
valuep = path.join(dir, value)
if name:
o = self.db.get_object(otype, name)
if module: o.add_value(module)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if modulep is not None: o.set_attr('path', modulep)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, name)
else:
id = ModuleObject.genid(module)
id = ModuleObject.genid(value)
o = self.db.get_object(otype, id)
if module: o.add_value(module)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if modulep is not None: o.set_attr('path', modulep)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, id)
def handle_xuinst(self, ltype, *args):
@ -837,29 +837,29 @@ class Parser(object):
# traiter les wobundles
for nvs in nvss:
name, values = split_nlist(nvs)
for wobundle in values:
for value in values:
dir = None
wobundlep = None
if wobundle:
if '/' in wobundle:
dir, wobundle = path.split(path.abspath(path.expanduser(wobundle)))
wobundle = self.__fix_wobundle(wobundle)
valuep = None
if value:
if '/' in value:
dir, value = path.split(path.abspath(path.expanduser(value)))
value = self.__fix_wobundle(value)
if dir is not None:
wobundlep = path.join(dir, wobundle)
valuep = path.join(dir, value)
if name:
o = self.db.get_object(otype, name)
if wobundle: o.add_value(wobundle)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if wobundlep is not None: o.set_attr('path', wobundlep)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, name)
else:
id = WobundleObject.genid(wobundle)
id = WobundleObject.genid(value)
o = self.db.get_object(otype, id)
if wobundle: o.add_value(wobundle)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if wobundlep is not None: o.set_attr('path', wobundlep)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, id)
def handle_rwoinst(self, cmd, *args):
@ -914,29 +914,29 @@ class Parser(object):
# traiter les webapps
for nvs in nvss:
name, values = split_nlist(nvs)
for webapp in values:
for value in values:
dir = None
webappp = None
if webapp:
if '/' in webapp:
dir, webapp = path.split(path.abspath(path.expanduser(webapp)))
webapp = self.__fix_webapp(webapp)
valuep = None
if value:
if '/' in value:
dir, value = path.split(path.abspath(path.expanduser(value)))
value = self.__fix_webapp(value)
if dir is not None:
webappp = path.join(dir, webapp)
valuep = path.join(dir, value)
if name:
o = self.db.get_object(otype, name)
if webapp: o.add_value(webapp)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if webappp is not None: o.set_attr('path', webappp)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, name)
else:
id = WebappObject.genid(webapp)
id = WebappObject.genid(value)
o = self.db.get_object(otype, id)
if webapp: o.add_value(webapp)
if value: o.add_value(value)
o.merge_attrs(defaulto)
if dir is not None: o.set_attr('dir', dir)
if webappp is not None: o.set_attr('path', webappp)
if valuep is not None: o.set_attr('path', valuep)
self.add_group(otype, id)
def handle_rtoinst(self, cmd, *args):