Example #1
0
def main(argv):
    usage = ""
    parser = OptionParser(usage=usage)
    parser.disable_interspersed_args()
    parser.add_option("-i", dest="super",
                      type="string",
                      help='Superclass')
    (options, args) = parser.parse_args(argv)

    if len(args) > 1:
        msg = 'Only one extra arg'
        raise Exception(msg)

    module_name = args[0]
    module = import_name(module_name)

    items = list(module.__dict__.items())

    if options.super is not None:
        options.super = import_name(options.super)

    def same_class(name, object):
        if options.super is None:
            return True
        if object == options.super:
            return False # getmro() returns also the class itself
        try:
            bases = inspect.getmro(object)
            return options.super in bases
        except Exception as e: # XXX 
            return False
        return True


    filters = [same_class]
    for f in filters:
        items = [x for x in items if f(*x)]

    items = sorted(items, key=lambda x: x[0])

    s = """
.. py:module:: %s

.. autosummary::  
   :toctree: api
   
""" % module_name

    for name, ob in items:
        s += ('   %s\n' % name)
    s += '\n\n'

    print(s)
Example #2
0
def main(argv):
    usage = ""
    parser = OptionParser(usage=usage)
    parser.disable_interspersed_args()
    parser.add_option("-i", dest="super", type="string", help='Superclass')
    (options, args) = parser.parse_args(argv)

    if len(args) > 1:
        msg = 'Only one extra arg'
        raise Exception(msg)

    module_name = args[0]
    module = import_name(module_name)

    items = list(module.__dict__.items())

    if options.super is not None:
        options.super = import_name(options.super)

    def same_class(name, object):
        if options.super is None:
            return True
        if object == options.super:
            return False  # getmro() returns also the class itself
        try:
            bases = inspect.getmro(object)
            return options.super in bases
        except Exception as e:  # XXX
            return False
        return True

    filters = [same_class]
    for f in filters:
        items = [x for x in items if f(*x)]

    items = sorted(items, key=lambda x: x[0])

    s = """
.. py:module:: %s

.. autosummary::  
   :toctree: api
   
""" % module_name

    for name, ob in items:
        s += ('   %s\n' % name)
    s += '\n\n'

    print(s)
Example #3
0
def instance_comptests_jobs2_m(context, module_name, create_reports):
    from .registrar import jobs_registrar_simple
    is_first =  '.' not in module_name
    warn_errors = is_first

    try:
        module = import_name(module_name)
    except ValueError as e:

        msg = 'Could not import module %r' % module_name

        if warn_errors:
            logger.error(msg)

        raise_wrapped(Exception, e, msg)
        assert False

    fname = CompTests.hook_name

    if not fname in module.__dict__:
        msg = 'Module %s does not have function %s().' % (module_name, fname)
        if warn_errors:
            logger.debug(msg)
    else:
        ff = module.__dict__[fname]
        context.comp_dynamic(comptests_jobs_wrap, ff, job_id=module_name)

    jobs_registrar_simple(context, only_for_module=module_name)
Example #4
0
def instance_comptests_jobs2_m(context, module_name, create_reports):
    is_first = not '.' in module_name
    warn_errors = is_first

    try:
        module = import_name(module_name)
    except ValueError as e:
        if warn_errors:
            print(e)  # 'Could not import %r: %s' % (module_name, e))
            raise Exception(e)
        return []
    
    fname = CompTests.hook_name
    
    if not fname in module.__dict__:
        msg = 'Module %s does not have function %s().' % (module_name, fname)
        if warn_errors:
            print(msg)
        return []

    ff = module.__dict__[fname]

    context.comp_dynamic(comptests_jobs_wrap, ff, job_id=module_name)
def batch_set(data_central, id_set, spec):  # @UnusedVariable
    function_name = spec['code'][0]
    args = spec['code'][1]
    function = import_name(function_name)
    function(data_central=data_central, **args)