Dynamic method creation can be used to create the methods for the cobbler nouns. A single loop can create all the wrappers:

 

Adding the following code to api.__init__ will create all the find_xxxx() methods:

 

        for what in ['distro','profile','system','repo','image','network']:

            codestr='''

                def find_%s(self, name=None, return_list=False, no_errors=False, **kargs):

                    return self._config.%ss().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)

            ''' % (what,what)

            d={}

            exec codestr.strip() in d

            setattr(self.__class__, 'find_%s' % what, d['find_%s' % what])

 

Regards,

Peter

 


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.