当前位置: 首页>>代码示例>>Python>>正文


Python astng.MANAGER类代码示例

本文整理汇总了Python中logilab.astng.MANAGER的典型用法代码示例。如果您正苦于以下问题:Python MANAGER类的具体用法?Python MANAGER怎么用?Python MANAGER使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MANAGER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_option

 def set_option(self, opt_name, value, action=None, opt_dict=None):
     """overridden from configuration.OptionsProviderMixin to handle some
     special options
     """
     if opt_name in self._options_methods:
         if value:
             meth = self._options_methods[opt_name]
             value = check_csv(None, opt_name, value)
             if isinstance(value, (list, tuple)):
                 for _id in value :
                     meth(_id)
             else :
                 meth(value)
     elif opt_name == 'cache-size':
         MANAGER.set_cache_size(int(value))
     elif opt_name == 'output-format':
         self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
     elif opt_name in ('enable-checker', 'disable-checker'):
         if not value:
             return
         checkerids = [v.lower() for v in check_csv(None, opt_name, value)]
         self.enable_checkers(checkerids, opt_name == 'enable-checker')
     try:
         BaseRawChecker.set_option(self, opt_name, value, action, opt_dict)
     except UnsupportedAction:
         print >>sys.stderr, 'option %s can\'t be read from config file' % opt_name
开发者ID:facuman,项目名称:environment,代码行数:26,代码来源:lint.py

示例2: import_module

 def import_module(self, modname, relative_only=False, level=None):
     """import the given module considering self as context"""
     try:
         absmodname = self.absolute_modname(modname, level)
         return MANAGER.astng_from_module_name(absmodname)
     except ASTNGBuildingException:
         # we only want to import a sub module or package of this module,
         # skip here
         if relative_only:
             raise
     module = MANAGER.astng_from_module_name(modname)
     return module
开发者ID:mozilla,项目名称:FlightDeck-lib,代码行数:12,代码来源:scoped_nodes.py

示例3: register

def register(linter):
    if PYLINT == 0:
        if hasattr(MANAGER, 'register_transformer'):
            MANAGER.register_transformer(ssl_transform)
        else:
            safe = builder.ASTNGBuilder.string_build
            def _string_build(self, data, modname='', path=None):
                if modname == 'ssl':
                    data += '\n\nPROTOCOL_SSLv23 = 0\nPROTOCOL_TLSv1 = 0'
                return safe(self, data, modname, path)
            builder.ASTNGBuilder.string_build = _string_build
    else:
        MANAGER.register_transform(scoped_nodes.Module, ssl_transform)
开发者ID:Bcfg2,项目名称:bcfg2,代码行数:13,代码来源:ssl_protocols.py

示例4: test_inspect_build0

 def test_inspect_build0(self):
     """test astng tree build from a living object"""
     builtin_astng = MANAGER.astng_from_module_name('__builtin__')
     fclass = builtin_astng['file']
     self.assert_('name' in fclass)
     self.assert_('mode' in fclass)
     self.assert_('read' in fclass)
     self.assert_(fclass.newstyle)
     self.assert_(fclass.pytype(), '__builtin__.type')
     self.assertIsInstance(fclass['read'], nodes.Function)
     # check builtin function has args.args == None
     dclass = builtin_astng['dict']
     self.assertEquals(dclass['has_key'].args.args, None)
     # just check type and object are there
     builtin_astng.getattr('type')
     builtin_astng.getattr('object')
     # check open file alias
     builtin_astng.getattr('open')
     # check 'help' is there (defined dynamically by site.py)
     builtin_astng.getattr('help')
     # check property has __init__
     pclass = builtin_astng['property']
     self.assert_('__init__' in pclass)
     self.assertIsInstance(builtin_astng['None'], nodes.Const)
     self.assertIsInstance(builtin_astng['True'], nodes.Const)
     self.assertIsInstance(builtin_astng['False'], nodes.Const)
     self.assertIsInstance(builtin_astng['Exception'], nodes.From)
     self.assertIsInstance(builtin_astng['NotImplementedError'], nodes.From)
开发者ID:AndryulE,项目名称:kitsune,代码行数:28,代码来源:unittest_builder.py

示例5: infer_empty_node

def infer_empty_node(self, context=None):
    if not self.has_underlying_object():
        yield YES
    else:
        try:
            for infered in MANAGER.infer_astng_from_something(self.object, context=context):
                yield infered
        except ASTNGError:
            yield YES
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: test_functional_relation_extraction

 def test_functional_relation_extraction(self):
     """functional test of relations extraction;
     different classes possibly in different modules"""
     # XXX should be catching pyreverse environnement problem but doesn't
     # pyreverse doesn't extracts the relations but this test ok
     project = MANAGER.project_from_files(["data"], astng_wrapper)
     handler = DiadefsHandler(Config())
     diadefs = handler.get_diadefs(project, Linker(project, tag=True))
     cd = diadefs[1]
     relations = _process_relations(cd.relationships)
     self.assertEquals(relations, self._should_rels)
开发者ID:Zucus,项目名称:kitsune,代码行数:11,代码来源:unittest_pyreverse_diadefs.py

示例7: get_astng

 def get_astng(self, filepath, modname):
     """return a astng representation for a module"""
     try:
         return MANAGER.astng_from_file(filepath, modname, source=True)
     except SyntaxError as ex:
         self.add_message('E0001', line=ex.lineno, args=ex.msg)
     except ASTNGBuildingException as ex:
         self.add_message('F0010', args=ex)
     except Exception as ex:
         import traceback
         traceback.print_exc()
         self.add_message('F0002', args=(ex.__class__, ex))
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:12,代码来源:lint.py

示例8: test_known_values2

 def test_known_values2(self):
     project = MANAGER.project_from_files(['data.clientmodule_test'], astng_wrapper)
     dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
     self.assertEqual(len(dd), 1)
     keys = [d.TYPE for d in dd]
     self.assertEqual(keys, ['class'])
     cd = dd[0]
     self.assertEqual(cd.title, 'classes No Name')
     classes = _process_classes(cd.objects)
     self.assertEqual(classes, [(True, 'Ancestor'),
                                (True, 'DoNothing'),
                                (True, 'Specialization')]
                       )
开发者ID:Chaos99,项目名称:cachetools,代码行数:13,代码来源:unittest_pyreverse_diadefs.py

示例9: builtin_lookup

def builtin_lookup(name):
    """lookup a name into the builtin module
    return the list of matching statements and the astng for the builtin
    module
    """
    builtinastng = MANAGER.astng_from_module(__builtin__)
    if name == '__dict__':
        return builtinastng, ()
    try:
        stmts = builtinastng.locals[name]
    except KeyError:
        stmts = ()
    return builtinastng, stmts
开发者ID:steverecio,项目名称:.emacs.d,代码行数:13,代码来源:lookup.py

示例10: test_inspect_build_type_object

    def test_inspect_build_type_object(self):
        builtin_astng = MANAGER.astng_from_module_name('__builtin__')

        infered = list(builtin_astng.igetattr('object'))
        self.assertEquals(len(infered), 1)
        infered = infered[0]
        self.assertEquals(infered.name, 'object')
        as_string(infered)

        infered = list(builtin_astng.igetattr('type'))
        self.assertEquals(len(infered), 1)
        infered = infered[0]
        self.assertEquals(infered.name, 'type')
        as_string(infered)
开发者ID:AndryulE,项目名称:kitsune,代码行数:14,代码来源:unittest_builder.py

示例11: test_known_values2

 def test_known_values2(self):
     project = MANAGER.project_from_files(["data.clientmodule_test"], astng_wrapper)
     dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
     self.assertEquals(len(dd), 1)
     keys = [d.TYPE for d in dd]
     self.assertEquals(keys, ["class"])
     cd = dd[0]
     self.assertEquals(cd.title, "classes No Name")
     classes = _process_classes(cd.objects)
     self.assertEquals(
         classes,
         [
             {"node": True, "name": "Ancestor"},
             {"node": True, "name": "DoNothing"},
             {"node": True, "name": "Specialization"},
         ],
     )
开发者ID:Zucus,项目名称:kitsune,代码行数:17,代码来源:unittest_pyreverse_diadefs.py

示例12: test_pylint_config_attr

 def test_pylint_config_attr(self):
     try:
         from pylint import lint
     except ImportError:
         self.skipTest('pylint not available')
     mod = MANAGER.astng_from_module_name('pylint.lint')
     pylinter = mod['PyLinter']
     expect = ['OptionsManagerMixIn', 'object', 'MessagesHandlerMixIn',
               'ReportsHandlerMixIn', 'BaseRawChecker', 'BaseChecker',
               'OptionsProviderMixIn', 'ASTWalker']
     self.assertListEqual([c.name for c in pylinter.ancestors()],
                          expect)
     self.assert_(list(Instance(pylinter).getattr('config')))
     infered = list(Instance(pylinter).igetattr('config'))
     self.assertEqual(len(infered), 1)
     self.assertEqual(infered[0].root().name, 'optparse')
     self.assertEqual(infered[0].name, 'Values')
开发者ID:Chaos99,项目名称:cachetools,代码行数:17,代码来源:unittest_regrtest.py

示例13: add_ormobject

    def add_ormobject(self, orm_type, orm_name):
        if orm_type in dt.done:
            return
        dt.done.add(orm_type)
        module_name = orm_type.__module__
        pymodule = namedAny(module_name)
        assert pymodule
        module = MANAGER.astng_from_module(pymodule)
        assert module
        class_node = module[orm_name]

        t = ''
        t += 'class %s:\n' % (orm_name, )

        t += '    q = None\n'
        t += '    _connection = None\n'

        orm_ti = dt.orm_classes.get(orm_name)
        if orm_ti is not None:
            for name in sorted(orm_ti.get_column_names()):
                t += '    %s = None\n' % (name, )

            for name, class_name in sorted(orm_ti.get_foreign_columns()):
                self.add_ormobject(dt.orm_classes[class_name].orm_type,
                                   class_name)
                t += '    %s = None\n' % (class_name, )
                t += '    %s = %s()\n' % (name, class_name)

            for name, class_name in sorted(orm_ti.get_single_joins()):
                self.add_ormobject(
                    dt.orm_classes[class_name].orm_type,
                    class_name)
                t += '    %s = %s()\n' % (name, class_name)

        t += '\n'
        nodes = self.builder.string_build(t)
        for key, value in nodes[orm_name].items():
            class_node.locals[key] = [value]
开发者ID:esosaja,项目名称:stoq-utils,代码行数:38,代码来源:pylint_stoq.py

示例14: nose_transform

from nose import tools


function_template = """
def {}(*args, **kwargs):
    pass
"""


def nose_transform(module):
    funcs = ''.join(function_template.format(func_name)
                    for func_name in tools.__all__)
    fake = ASTNGBuilder(MANAGER).string_build(funcs)

    for func_name in tools.__all__:
        if func_name not in module.locals:
            module.locals[func_name] = fake[func_name]


def transform(module):
    if module.name == 'nose.tools':
        nose_transform(module)

from logilab.astng import MANAGER
MANAGER.register_transformer(transform)


def register(linter):
    pass
开发者ID:OddBloke,项目名称:pylint-nose-checker,代码行数:29,代码来源:nose_checker.py

示例15: get_astng

 def get_astng(self, filepath, modname):
     """return a astng representation for a module"""
     try:
         return MANAGER.astng_from_file(filepath, modname)
     except SyntaxError, ex:
         self.add_message('E0001', line=ex.lineno, args=ex.msg)
开发者ID:facuman,项目名称:environment,代码行数:6,代码来源:lint.py


注:本文中的logilab.astng.MANAGER类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。