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


Python reflect.namedAny函数代码示例

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


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

示例1: test_listingModulesAlreadyImported

 def test_listingModulesAlreadyImported(self):
     """ Make sure the module list comes back as we expect from iterModules on a
     package, whether zipped or not, even if the package has already been
     imported.  """
     self._setupSysPath()
     namedAny(self.packageName)
     self._listModules()
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:7,代码来源:test_modules.py

示例2: getPluginMethods

    def getPluginMethods(cls, plugin_name = None):
        # Get plugin by name or pk
        if plugin_name:
            plugin_list = Plugin.objects(name = plugin_name)
        else:
            plugin_list = Plugin.objects

        # Parse plugins
        listallmethods = []
        for plugin in plugin_list:
            plugininstance = namedAny('.'.join(('lisa.plugins', str(plugin.name), 'modules', str(plugin.name).lower(), str(plugin.name))))()
            listpluginmethods = []
            for m in inspect.getmembers(plugininstance, predicate = inspect.ismethod):
                if not "__init__" in m and not m.startswith("_"):
                    listpluginmethods.append(m[0])
            listallmethods.append({'plugin': plugin.name, 'methods': listpluginmethods})

        # Parse core plugins
        for f in os.listdir(os.path.normpath(server_path + '/core')):
            fileName, fileExtension = os.path.splitext(f)
            if os.path.isfile(os.path.join(os.path.normpath(server_path + '/core'), f)) and not f.startswith('__init__') and fileExtension != '.pyc':
                coreinstance = namedAny('.'.join(('lisa.server.core', str(fileName).lower(), str(fileName).capitalize())))()
                listcoremethods = []
                for m in inspect.getmembers(coreinstance, predicate = inspect.ismethod):
                    #init shouldn't be listed in methods and _ is for translation
                    if not "__init__" in m and not m.startswith("_"):
                        listcoremethods.append(m[0])
                listallmethods.append({'core': fileName, 'methods': listcoremethods})

        log.msg(listallmethods)
        return listallmethods
开发者ID:gdumee,项目名称:LISA,代码行数:31,代码来源:PluginManager.py

示例3: test_noversionpy

 def test_noversionpy(self):
     """
     Former subprojects no longer have an importable C{_version.py}.
     """
     with self.assertRaises(AttributeError):
         reflect.namedAny(
             "twisted.{}._version".format(self.subproject))
开发者ID:Architektor,项目名称:PySnip,代码行数:7,代码来源:test_twisted.py

示例4: start

        def start():
            node_to_instance = {
                u"client": lambda: maybeDeferred(namedAny("allmydata.client.create_client"), self.basedir),
                u"introducer": lambda: maybeDeferred(namedAny("allmydata.introducer.server.create_introducer"), self.basedir),
                u"stats-gatherer": lambda: maybeDeferred(namedAny("allmydata.stats.StatsGathererService"), read_config(self.basedir, None), self.basedir, verbose=True),
                u"key-generator": key_generator_removed,
            }

            try:
                service_factory = node_to_instance[self.nodetype]
            except KeyError:
                raise ValueError("unknown nodetype %s" % self.nodetype)

            def handle_config_error(fail):
                fail.trap(UnknownConfigError)
                sys.stderr.write("\nConfiguration error:\n{}\n\n".format(fail.value))
                reactor.stop()
                return

            d = service_factory()

            def created(srv):
                srv.setServiceParent(self.parent)
            d.addCallback(created)
            d.addErrback(handle_config_error)
            d.addBoth(self._call_hook, 'running')
            return d
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:27,代码来源:tahoe_daemonize.py

示例5: test_client

 def test_client(self):
     """
     The L{insults.client} module is deprecated
     """
     namedAny('twisted.conch.insults.client')
     self.ensureDeprecated("twisted.conch.insults.client was deprecated "
                           "in Twisted 10.1.0: Please use "
                           "twisted.conch.insults.insults instead.")
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:8,代码来源:test_insults.py

示例6: test_colors

 def test_colors(self):
     """
     The L{insults.colors} module is deprecated
     """
     namedAny('twisted.conch.insults.colors')
     self.ensureDeprecated("twisted.conch.insults.colors was deprecated "
                           "in Twisted 10.1.0: Please use "
                           "twisted.conch.insults.helper instead.")
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:8,代码来源:test_insults.py

示例7: load

def load(S):
    for line in S.split('\n'):
        line = line.strip()
        if line and not line.startswith('#'):
            (a, o , i) = line.split()
            a = reflect.namedAny(a)
            o = reflect.namedAny(o)
            i = reflect.namedAny(i)
            compy.registerAdapter(a,o,i)
开发者ID:BackupTheBerlios,项目名称:weever-svn,代码行数:9,代码来源:__init__.py

示例8: test_NMEADeprecation

 def test_NMEADeprecation(self):
     """
     L{twisted.protocols.gps.nmea} is deprecated since Twisted 15.2.
     """
     reflect.namedAny("twisted.protocols.gps.nmea")
     warningsShown = self.flushWarnings()
     self.assertEqual(1, len(warningsShown))
     self.assertEqual(
         "twisted.protocols.gps was deprecated in Twisted 15.2.0: "
         "Use twisted.positioning instead.", warningsShown[0]['message'])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:10,代码来源:test_basic.py

示例9: test_loreDeprecation

 def test_loreDeprecation(self):
     """
     L{twisted.lore} is deprecated since Twisted 14.0.
     """
     reflect.namedAny("twisted.lore")
     warningsShown = self.flushWarnings()
     self.assertEqual(1, len(warningsShown))
     self.assertEqual(
         "twisted.lore was deprecated in Twisted 14.0.0: "
         "Use Sphinx instead.", warningsShown[0]['message'])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:10,代码来源:test_twisted.py

示例10: test_MiceDeprecation

 def test_MiceDeprecation(self):
     """
     L{twisted.protocols.mice} is deprecated since Twisted 16.0.
     """
     reflect.namedAny("twisted.protocols.mice")
     warningsShown = self.flushWarnings()
     self.assertEqual(1, len(warningsShown))
     self.assertEqual(
         "twisted.protocols.mice was deprecated in Twisted 16.0.0: "
         "There is no replacement for this module.",
         warningsShown[0]['message'])
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:11,代码来源:test_basic.py

示例11: update_params

 def update_params(self, d):
     super(SourceCodeWidget, self).update_params(d)
     title = d.widget.__class__.__name__
     if not d.source:
         try:
             d.widget = moksha.get_widget(d.widget)
         except Exception, e:
             d.widget = namedAny(d.widget)
         if d.module:
             obj = namedAny(d.widget.__module__)
         else:
             obj = d.widget.__class__
         d.source = inspect.getsource(obj)
开发者ID:lmacken,项目名称:moksha,代码行数:13,代码来源:source.py

示例12: start

        def start():
            node_to_instance = {
                u"client": lambda: namedAny("allmydata.client.create_client")(self.basedir),
                u"introducer": lambda: namedAny("allmydata.introducer.server.create_introducer")(self.basedir),
                u"stats-gatherer": lambda: namedAny("allmydata.stats.StatsGathererService")(read_config(self.basedir, None), self.basedir, verbose=True),
                u"key-generator": key_generator_removed,
            }

            try:
                service_factory = node_to_instance[self.nodetype]
            except KeyError:
                raise ValueError("unknown nodetype %s" % self.nodetype)

            srv = service_factory()
            srv.setServiceParent(self.parent)
开发者ID:warner,项目名称:tahoe-lafs,代码行数:15,代码来源:tahoe_daemonize.py

示例13: pipedpath_constructor

def pipedpath_constructor(loader, node):
    path = loader.construct_python_str(node)
    original_path = path
    package = piped
    
    # the path may be an empty string, which should be the root piped package path.
    if path:
        paths = path.split(os.path.sep)

        for i in range(1, len(paths)+1):
            package_name = '.'.join(['piped'] + paths[:i])

            try:
                any = reflect.namedAny(package_name)
            except (AttributeError, reflect.ObjectNotFound) as e:
                # AttributeErrors may occur if we look a file that has the
                # same prefix as an existing module or package
                break

            # we don't want to start looking into modules:
            if not is_package(any):
                break
            package = any

            # update the remaining path
            path = os.path.sep.join(paths[i:])

    root = filepath.FilePath(package.__file__).parent()
    fp = root.preauthChild(util.expand_filepath(path))

    # add markers for dumping the configuration
    fp.origpath = original_path
    fp.pipedpath = True
    return fp
开发者ID:alexbrasetvik,项目名称:Piped,代码行数:34,代码来源:yamlutil.py

示例14: _tryNamedAny

    def _tryNamedAny(self, arg):
        try:
            try:
                n = reflect.namedAny(arg)
            except ValueError, ve:
                if ve.args == ('Empty module name',):
                    raise ArgumentError
                else:
                    raise
        except ArgumentError:
            raise
        except:
            f = failure.Failure()
            f.printTraceback()
            self['_couldNotImport'][arg] = f
            return

        # okay, we can use named any to import it, so now wtf is it?
        if inspect.ismodule(n):
            filename = os.path.basename(n.__file__)
            filename = os.path.splitext(filename)[0]
            if filename == '__init__':
                self['packages'].append(n)
            else:
                self['modules'].append(n)
        elif inspect.isclass(n):
            self['testcases'].append(n)
        elif inspect.ismethod(n):
            self['methods'].append(n)
        else:
            raise ArgumentError, "could not figure out how to use %s" % arg
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:31,代码来源:trial.py

示例15: __init__

    def __init__(self, profile_name, engine, events=None, checkout=None, checkin=None, ping_interval=10.0, retry_interval=5.0):
        super(EngineManager, self).__init__()
        self.profile_name = profile_name
        self.ping_interval = ping_interval
        self.retry_interval = retry_interval

        self.events = {} if events is None else events
        self.checkout = [] if checkout is None else checkout
        self.checkin = [] if checkin is None else checkin

        self.engine_configuration = copy.deepcopy(engine)
        self._fail_if_configuration_is_invalid()
        self.engine_configuration.setdefault('proxy', self.proxy_factory(self))

        if 'poolclass' in self.engine_configuration:
            self.engine_configuration['poolclass'] = reflect.namedAny(self.engine_configuration['poolclass'])

        self.is_connected = False

        self.engine = sa.engine_from_config(self.engine_configuration, prefix='')
        self._bind_events()

        self.on_connection_established = event.Event()
        self.on_connection_lost = event.Event()
        self.on_connection_failed = event.Event()
开发者ID:hooplab,项目名称:piped-contrib-database,代码行数:25,代码来源:db.py


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