• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reflect.namedAny函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: render_examples

 def render_examples(self, ctx, data):
     for name in examples:
         cls = reflect.namedAny(name)
         yield T.div(class_='example')[
             T.h1[T.a(href=url.here.child(name))[cls.title]],
             T.p[cls.description],
             ]
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:7,代码来源:main.py


示例17: _getChildPerms

    def _getChildPerms(self, childAuthor):
        """
        Get the permissions that should be applied to a child of this blurb

        @param childAuthor: the author of the child blurb
        @type childAuthor: L{xmantissa.sharing.Role}

        @return: mapping of roles to interfaces
        @rtype: C{dict} of L{xmantissa.sharing.Role} to C{list} of
        L{zope.interface.Interface}
        """
        # By default, the author is allowed to edit and comment upon their own
        # entries.  Not even the owner of the area gets to edit (although they
        # probably get to delete).
        roleToPerms = {childAuthor: [ihyperbola.IEditable, ihyperbola.ICommentable]}
        currentBlurb = self

        # With regards to permission, children supersede their parents.  For
        # example, if you want to lock comments on a particular entry, you can
        # give it a new FlavorPermission and its parents will no longer
        # override.  We are specifically iterating upwards from the child here
        # for this reason.
        newFlavor = FLAVOR.commentFlavors[self.flavor]
        while currentBlurb is not None:
            for fp in self.store.query(
                FlavorPermission, AND(FlavorPermission.flavor == newFlavor, FlavorPermission.blurb == currentBlurb)
            ):
                # This test makes sure the parent doesn't override by
                # clobbering the entry in the dictionary.
                if fp.role not in roleToPerms:
                    roleToPerms[fp.role] = [namedAny(x.encode("ascii")) for x in fp.permissions]
            currentBlurb = currentBlurb.parent
        return roleToPerms
开发者ID:pombredanne,项目名称:hyperbola,代码行数:33,代码来源:hyperblurb.py


示例18: tryImports

def tryImports(*names):
    for name in names:
        try:
            return namedAny(name)
        except ObjectNotFound:
            pass
    raise
开发者ID:hybridlogic,项目名称:txHybridCluster,代码行数:7,代码来源:utils.py


示例19: make_loop_proxy

def make_loop_proxy(params):
    target = params.get('target')
    timeout = params.get('timeout', 60.0)
    if isinstance(target, basestring):
        target = reflect.namedAny(target)
    logger.debug("create loop-rpc-proxy, target is %r", target)
    return LoopRPCProxy(target=target, timeout=timeout)
开发者ID:wgnet,项目名称:twoost,代码行数:7,代码来源:rpcproxy.py


示例20: getResults

    def getResults(self):
        """ return resultset
		"""
        if self.isValidRequest():
            if self.dataChanged == False:
                self.results = None
                try:
                    self.modelClass = namedAny(self.requestObj["sourcetable"])
                    self.modelObj = self.modelClass()
                    self.searchstring = self.requestObj["searchstring"]
                    colName = self.requestObj["column"]
                    attr = getattr(self.modelObj, colName)
                    op = self.requestObj["operation"]
                    print "Operation = ", op, "colName = ", colName.strip(), "sourcestring = ", self.searchstring
                    if op == "in":
                        lookup = "%s__contains" % colName.strip()
                    elif op == "eq":
                        lookup = "%s__exact" % colName.strip()
                    elif op == "sw":
                        lookup = "%s__startswith" % colName.strip()
                    elif op == "ew":
                        lookup = "%s__endswith" % colName.strip()

                    query = {lookup: self.searchstring}
                    self.results = list(self.modelClass.objects.filter(**query).values())
                except:
                    e = sys.exc_info()[0]
                    print "Exception in AutocompleteRequest.getResults():", e
                    pass
        else:
            self.results = None
        self.dataChanged = True
        return self.results
开发者ID:psiCode,项目名称:shoutserver,代码行数:33,代码来源:autocompleterequest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reflect.namedObject函数代码示例发布时间:2022-05-27
下一篇:
Python reflect.fullyQualifiedName函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap