twisted.python.reflect.namedAny - python examples

Here are the examples of the python api twisted.python.reflect.namedAny taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

33 Examples 7

3 View Complete Implementation : trial.py
Copyright MIT License
Author : adde88
    def _loadReporterByName(self, name):
        for p in plugin.getPlugins(itrial.IReporter):
            qual = "%s.%s" % (p.module, p.klast)
            if p.longOpt == name:
                return reflect.namedAny(qual)
        raise usage.UsageError("Only past names of Reporter plugins to "
                               "--reporter. See --help-reporters for "
                               "more info.")

3 View Complete Implementation : test_modules.py
Copyright MIT License
Author : adde88
    def test_loadPackagesAndModules(self):
        """ Verify that we can locate and load packages, modules, submodules, and
        subpackages.  """
        for n in ['os',
                  'twisted',
                  'twisted.python',
                  'twisted.python.reflect']:
            m = namedAny(n)
            self.failUnlessIdentical(
                modules.getModule(n).load(),
                m)
            self.failUnlessIdentical(
                self.findByIteration(n).load(),
                m)

3 View Complete Implementation : test_modules.py
Copyright MIT License
Author : adde88
    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()

3 View Complete Implementation : runner.py
Copyright MIT License
Author : adde88
    def findByName(self, name):
        """
        Return a Python object given a string describing it.

        @param name: a string which may be either a filename or a
        fully-qualified Python name.

        @return: If C{name} is a filename, return the module. If C{name} is a
        fully-qualified Python name, return the object it refers to.
        """
        if os.path.exists(name):
            return filenameToModule(name)
        return reflect.namedAny(name)

3 View Complete Implementation : runner.py
Copyright MIT License
Author : adde88
    def loadDoctests(self, module):
        """
        Return a suite of tests for all the doctests defined in C{module}.

        @param module: A module object or a module name.
        """
        if isinstance(module, str):
            try:
                module = reflect.namedAny(module)
            except:
                return ErrorHolder(module, failure.Failure())
        if not inspect.ismodule(module):
            warnings.warn("trial only supports doctesting modules")
            return
        return DocTestSuite(module)

3 View Complete Implementation : sim.py
Copyright Apache License 2.0
Author : apple
    @clastmethod
    def _convertDistribution(cls, value):
        """
        Construct and return a new distribution object using the type and
        params specified by C{value}.
        """
        return namedAny(value['type'])(**value['params'])

3 View Complete Implementation : migrate.py
Copyright Apache License 2.0
Author : apple
    @Configure.responder
    def configure(self, filename, appropriateStoreClast, merge):
        subsvc = None
        from txdav.common.datastore.file import CommonDataStore as FileStore
        self.upgrader = UpgradeToDatabaseStep(
            FileStore(
                CachingFilePath(filename), None, None, True, True,
                propertyStoreClast=namedAny(appropriateStoreClast)
            ), self.store, subsvc, merge=merge
        )
        return {}

3 View Complete Implementation : test_migrate.py
Copyright Apache License 2.0
Author : apple
    @CreateStore.responder
    def createStore(self, delegateTo):
        """
        Create a store and past it to the named delegate clast.
        """
        swapAMP(self, namedAny(delegateTo)(SQLStoreBuilder.childStore()))
        return {}

3 View Complete Implementation : test_migrate.py
Copyright Apache License 2.0
Author : apple
    @PickleConfig.responder
    def pickleConfig(self, config, delegateTo):
        # from twistedcaldav.config import config as globalConfig
        # globalConfig._data = config._data
        swapAMP(self, namedAny(delegateTo)(config))
        return {}

3 View Complete Implementation : app.py
Copyright MIT License
Author : wistbean
    def postOptions(self):
        if self.subCommand or self['python']:
            self['no_save'] = True
        if self['logger'] is not None:
            try:
                self['logger'] = namedAny(self['logger'])
            except Exception as e:
                raise usage.UsageError("Logger '%s' could not be imported: %s"
                                       % (self['logger'], e))