commencer à générifier un peu le code
This commit is contained in:
parent
8e48af9373
commit
41f4e724bd
|
@ -527,7 +527,7 @@ class Parser(object):
|
||||||
elif cmd == 'default_domain': self.handle_default_domain(args)
|
elif cmd == 'default_domain': self.handle_default_domain(args)
|
||||||
elif cmd == 'group': self.handle_group(args)
|
elif cmd == 'group': self.handle_group(args)
|
||||||
elif cmd == 'attr': self.handle_attr(args)
|
elif cmd == 'attr': self.handle_attr(args)
|
||||||
elif cmd == 'host': self.handle_host(args)
|
elif cmd == 'host': self.handle_host(*p)
|
||||||
elif cmd in self.commands: self.commands[cmd](*p)
|
elif cmd in self.commands: self.commands[cmd](*p)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ class Parser(object):
|
||||||
host = '%s.%s' % (host, self.db.default_domain)
|
host = '%s.%s' % (host, self.db.default_domain)
|
||||||
return host
|
return host
|
||||||
|
|
||||||
def handle_host(self, args):
|
def handle_host(self, otype, *args):
|
||||||
"""host [id=]host,...
|
"""host [id=]host,...
|
||||||
host -b [id=]basedir
|
host -b [id=]basedir
|
||||||
host -d [id=]dirspec
|
host -d [id=]dirspec
|
||||||
|
@ -636,9 +636,9 @@ class Parser(object):
|
||||||
if path.isdir(dir)])
|
if path.isdir(dir)])
|
||||||
nvss.extend(o.nvss)
|
nvss.extend(o.nvss)
|
||||||
# préparer la mise à jour du groupe courant
|
# préparer la mise à jour du groupe courant
|
||||||
self.reset_group_maybe('host')
|
self.reset_group_maybe(otype)
|
||||||
self.attr_otype = 'host'
|
self.attr_otype = otype
|
||||||
defaulto = self.db.get_object('host', None)
|
defaulto = self.db.get_object(otype, None)
|
||||||
# traiter les hôtes
|
# traiter les hôtes
|
||||||
for nvs in nvss:
|
for nvs in nvss:
|
||||||
name, values = split_nlist(nvs)
|
name, values = split_nlist(nvs)
|
||||||
|
@ -649,25 +649,25 @@ class Parser(object):
|
||||||
dir, host = path.split(path.abspath(path.expanduser(host)))
|
dir, host = path.split(path.abspath(path.expanduser(host)))
|
||||||
host = self.__fix_host(host)
|
host = self.__fix_host(host)
|
||||||
if name:
|
if name:
|
||||||
o = self.db.get_object('host', name)
|
o = self.db.get_object(otype, name)
|
||||||
if host: o.add_value(host)
|
if host: o.add_value(host)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
self.add_group('host', name)
|
self.add_group(otype, name)
|
||||||
else:
|
else:
|
||||||
id = HostObject.genid(host)
|
id = HostObject.genid(host)
|
||||||
o = self.db.get_object('host', id)
|
o = self.db.get_object(otype, id)
|
||||||
o.add_value(host)
|
o.add_value(host)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
self.add_group('host', id)
|
self.add_group(otype, id)
|
||||||
|
|
||||||
ib = HostObject.genib(id)
|
ib = HostObject.genib(id)
|
||||||
o = self.db.get_object('host', ib)
|
o = self.db.get_object(otype, ib)
|
||||||
o.add_value(host)
|
o.add_value(host)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
self.add_group('host', ib)
|
self.add_group(otype, ib)
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
def __setup_uinst(self):
|
def __setup_uinst(self):
|
||||||
|
@ -683,7 +683,7 @@ class Parser(object):
|
||||||
def __fix_module(self, module):
|
def __fix_module(self, module):
|
||||||
return module
|
return module
|
||||||
|
|
||||||
def handle_module(self, cmd, *args):
|
def handle_module(self, otype, *args):
|
||||||
"""module [id=]path/to/module
|
"""module [id=]path/to/module
|
||||||
module -b [id=]basedir
|
module -b [id=]basedir
|
||||||
module -d [id=]dirspec
|
module -d [id=]dirspec
|
||||||
|
@ -715,9 +715,9 @@ class Parser(object):
|
||||||
if path.isdir(dir)])
|
if path.isdir(dir)])
|
||||||
nvss.extend(o.nvss)
|
nvss.extend(o.nvss)
|
||||||
# préparer la mise à jour du groupe courant
|
# préparer la mise à jour du groupe courant
|
||||||
self.reset_group_maybe('module')
|
self.reset_group_maybe(otype)
|
||||||
self.attr_otype = 'module'
|
self.attr_otype = otype
|
||||||
defaulto = self.db.get_object('module', None)
|
defaulto = self.db.get_object(otype, None)
|
||||||
# traiter les modules
|
# traiter les modules
|
||||||
for nvs in nvss:
|
for nvs in nvss:
|
||||||
name, values = split_nlist(nvs)
|
name, values = split_nlist(nvs)
|
||||||
|
@ -731,20 +731,20 @@ class Parser(object):
|
||||||
if dir is not None:
|
if dir is not None:
|
||||||
modulep = path.join(dir, module)
|
modulep = path.join(dir, module)
|
||||||
if name:
|
if name:
|
||||||
o = self.db.get_object('module', name)
|
o = self.db.get_object(otype, name)
|
||||||
if module: o.add_value(module)
|
if module: o.add_value(module)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if modulep is not None: o.set_attr('path', modulep)
|
if modulep is not None: o.set_attr('path', modulep)
|
||||||
self.add_group('module', name)
|
self.add_group(otype, name)
|
||||||
else:
|
else:
|
||||||
id = ModuleObject.genid(module)
|
id = ModuleObject.genid(module)
|
||||||
o = self.db.get_object('module', id)
|
o = self.db.get_object(otype, id)
|
||||||
if module: o.add_value(module)
|
if module: o.add_value(module)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if modulep is not None: o.set_attr('path', modulep)
|
if modulep is not None: o.set_attr('path', modulep)
|
||||||
self.add_group('module', id)
|
self.add_group(otype, id)
|
||||||
|
|
||||||
def handle_xuinst(self, ltype, *args):
|
def handle_xuinst(self, ltype, *args):
|
||||||
"""uinst -p profile attrs*
|
"""uinst -p profile attrs*
|
||||||
|
@ -799,7 +799,7 @@ class Parser(object):
|
||||||
wobundle = wobundle + '.woa'
|
wobundle = wobundle + '.woa'
|
||||||
return wobundle
|
return wobundle
|
||||||
|
|
||||||
def handle_wobundle(self, cmd, *args):
|
def handle_wobundle(self, otype, *args):
|
||||||
"""wobundle [id=]path/to/wobundle
|
"""wobundle [id=]path/to/wobundle
|
||||||
wobundle -b [id=]basedir
|
wobundle -b [id=]basedir
|
||||||
wobundle -d [id=]dirspec
|
wobundle -d [id=]dirspec
|
||||||
|
@ -831,9 +831,9 @@ class Parser(object):
|
||||||
if path.isdir(dir) and path.splitext(dir)[1] in ('.woa', '.framework')])
|
if path.isdir(dir) and path.splitext(dir)[1] in ('.woa', '.framework')])
|
||||||
nvss.extend(o.nvss)
|
nvss.extend(o.nvss)
|
||||||
# préparer la mise à jour du groupe courant
|
# préparer la mise à jour du groupe courant
|
||||||
self.reset_group_maybe('wobundle')
|
self.reset_group_maybe(otype)
|
||||||
self.attr_otype = 'wobundle'
|
self.attr_otype = otype
|
||||||
defaulto = self.db.get_object('wobundle', None)
|
defaulto = self.db.get_object(otype, None)
|
||||||
# traiter les wobundles
|
# traiter les wobundles
|
||||||
for nvs in nvss:
|
for nvs in nvss:
|
||||||
name, values = split_nlist(nvs)
|
name, values = split_nlist(nvs)
|
||||||
|
@ -847,20 +847,20 @@ class Parser(object):
|
||||||
if dir is not None:
|
if dir is not None:
|
||||||
wobundlep = path.join(dir, wobundle)
|
wobundlep = path.join(dir, wobundle)
|
||||||
if name:
|
if name:
|
||||||
o = self.db.get_object('wobundle', name)
|
o = self.db.get_object(otype, name)
|
||||||
if wobundle: o.add_value(wobundle)
|
if wobundle: o.add_value(wobundle)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if wobundlep is not None: o.set_attr('path', wobundlep)
|
if wobundlep is not None: o.set_attr('path', wobundlep)
|
||||||
self.add_group('wobundle', name)
|
self.add_group(otype, name)
|
||||||
else:
|
else:
|
||||||
id = WobundleObject.genid(wobundle)
|
id = WobundleObject.genid(wobundle)
|
||||||
o = self.db.get_object('wobundle', id)
|
o = self.db.get_object(otype, id)
|
||||||
if wobundle: o.add_value(wobundle)
|
if wobundle: o.add_value(wobundle)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if wobundlep is not None: o.set_attr('path', wobundlep)
|
if wobundlep is not None: o.set_attr('path', wobundlep)
|
||||||
self.add_group('wobundle', id)
|
self.add_group(otype, id)
|
||||||
|
|
||||||
def handle_rwoinst(self, cmd, *args):
|
def handle_rwoinst(self, cmd, *args):
|
||||||
pass
|
pass
|
||||||
|
@ -876,7 +876,7 @@ class Parser(object):
|
||||||
def __fix_webapp(self, webapp):
|
def __fix_webapp(self, webapp):
|
||||||
return webapp
|
return webapp
|
||||||
|
|
||||||
def handle_webapp(self, cmd, *args):
|
def handle_webapp(self, otype, *args):
|
||||||
"""webapp [id=]path/to/webapp
|
"""webapp [id=]path/to/webapp
|
||||||
webapp -b [id=]basedir
|
webapp -b [id=]basedir
|
||||||
webapp -d [id=]dirspec
|
webapp -d [id=]dirspec
|
||||||
|
@ -908,9 +908,9 @@ class Parser(object):
|
||||||
if path.isdir(dir)])
|
if path.isdir(dir)])
|
||||||
nvss.extend(o.nvss)
|
nvss.extend(o.nvss)
|
||||||
# préparer la mise à jour du groupe courant
|
# préparer la mise à jour du groupe courant
|
||||||
self.reset_group_maybe('webapp')
|
self.reset_group_maybe(otype)
|
||||||
self.attr_otype = 'webapp'
|
self.attr_otype = otype
|
||||||
defaulto = self.db.get_object('webapp', None)
|
defaulto = self.db.get_object(otype, None)
|
||||||
# traiter les webapps
|
# traiter les webapps
|
||||||
for nvs in nvss:
|
for nvs in nvss:
|
||||||
name, values = split_nlist(nvs)
|
name, values = split_nlist(nvs)
|
||||||
|
@ -924,20 +924,20 @@ class Parser(object):
|
||||||
if dir is not None:
|
if dir is not None:
|
||||||
webappp = path.join(dir, webapp)
|
webappp = path.join(dir, webapp)
|
||||||
if name:
|
if name:
|
||||||
o = self.db.get_object('webapp', name)
|
o = self.db.get_object(otype, name)
|
||||||
if webapp: o.add_value(webapp)
|
if webapp: o.add_value(webapp)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if webappp is not None: o.set_attr('path', webappp)
|
if webappp is not None: o.set_attr('path', webappp)
|
||||||
self.add_group('webapp', name)
|
self.add_group(otype, name)
|
||||||
else:
|
else:
|
||||||
id = WebappObject.genid(webapp)
|
id = WebappObject.genid(webapp)
|
||||||
o = self.db.get_object('webapp', id)
|
o = self.db.get_object(otype, id)
|
||||||
if webapp: o.add_value(webapp)
|
if webapp: o.add_value(webapp)
|
||||||
o.merge_attrs(defaulto)
|
o.merge_attrs(defaulto)
|
||||||
if dir is not None: o.set_attr('dir', dir)
|
if dir is not None: o.set_attr('dir', dir)
|
||||||
if webappp is not None: o.set_attr('path', webappp)
|
if webappp is not None: o.set_attr('path', webappp)
|
||||||
self.add_group('webapp', id)
|
self.add_group(otype, id)
|
||||||
|
|
||||||
def handle_rtoinst(self, cmd, *args):
|
def handle_rtoinst(self, cmd, *args):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue