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


Python types.TypeType方法代码示例

本文整理汇总了Python中types.TypeType方法的典型用法代码示例。如果您正苦于以下问题:Python types.TypeType方法的具体用法?Python types.TypeType怎么用?Python types.TypeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types的用法示例。


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

示例1: get_gui

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def get_gui():
    proc, bits = get_architecture()
    mapping = {'intel' : IntelMask}

    if proc in mapping:
        gui = mapping[proc]
        if type(gui) != types.TypeType:
            #   For future use if mapping includes more of a breakdown
            return CASCMask(bits)

        return gui(bits)

    return CASCMask(bits)


#   Create ClamAV icon 
开发者ID:Cisco-Talos,项目名称:CASC,代码行数:18,代码来源:casc_plugin.py

示例2: newExperiment

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def newExperiment(self, experiment):
        """ Generate a new site information object """

        # get all classes
        experimentClasses = [j for (i,j) in globals().iteritems() if isinstance(j, TypeType) and issubclass(j, Experiment)]

        # loop over all subclasses
        for experimentClass in experimentClasses:
            si = experimentClass()

            # return the matching experiment class
            if si.getExperiment() == experiment:
                return experimentClass

        # if no class was found, raise an error
        raise ValueError('ExperimentFactory: No such class: "%s"' % (experiment)) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:18,代码来源:ExperimentFactory.py

示例3: newSiteInformation

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def newSiteInformation(self, experiment):
        """ Generate a new site information object """

        # get all classes
        siteInformationClasses = [j for (i,j) in globals().iteritems() if isinstance(j, TypeType) and issubclass(j, SiteInformation)]

        # loop over all subclasses
        for siteInformationClass in siteInformationClasses:
            si = siteInformationClass()

            # return the matching experiment class
            if si.getExperiment() == experiment:
                return siteInformationClass

        # if no class was found, raise an error
        raise ValueError('SiteInformationFactory: No such class: "%s"' % (experiment)) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:18,代码来源:SiteInformationFactory.py

示例4: newRunJob

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def newRunJob(self, _type="generic"):
        """ Generate a new site information object """



        # get all classes
        runJobClasses = [j for (i,j) in globals().iteritems() if isinstance(j, TypeType) and issubclass(j, RunJob)]
        
        # loop over all subclasses
        for runJobClass in runJobClasses:
            si = runJobClass()

            # return the matching RunJob class
            if si.getRunJob() == _type:
                return runJobClass

        # if no class was found, raise an error
        raise ValueError('RunJobFactory: No such class: "%s"' % (_type)) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:20,代码来源:RunJobFactory.py

示例5: newEventService

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def newEventService(self, experiment):
        """ Generate a new site information object """

        # get all classes
        eventServiceClasses = [j for (i,j) in globals().iteritems() if isinstance(j, TypeType) and issubclass(j, EventService)]
        print eventServiceClasses
        # loop over all subclasses

        if experiment == "Nordugrid-ATLAS":
            experiment = "ATLAS"
        for eventServiceClass in eventServiceClasses:
            si = eventServiceClass()

            # return the matching eventService class
            if si.getEventService() == experiment:
                return eventServiceClass

        # if no class was found, raise an error
        raise ValueError('EventServiceFactory: No such class: "%s"' % (eventServiceClass)) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:21,代码来源:EventServiceFactory.py

示例6: removeComponent

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def removeComponent(self, component):
        """
        Remove the given component from me entirely, for all interfaces for which
        it has been registered.

        @return: a list of the interfaces that were removed.
        """
        if (isinstance(component, types.ClassType) or
            isinstance(component, types.TypeType)):
            warnings.warn("passing interface to removeComponent, you probably want unsetComponent", DeprecationWarning, 1)
            self.unsetComponent(component)
            return [component]
        l = []
        for k, v in self._adapterCache.items():
            if v is component:
                del self._adapterCache[k]
                l.append(reflect.namedObject(k))
        return l 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:20,代码来源:components.py

示例7: is_exc_info_tuple

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def is_exc_info_tuple(exc_info):
    """Determine whether 'exc_info' is an exc_info tuple.

    Note: exc_info tuple means a tuple of exception related values
    as returned by sys.exc_info().
    """
    try:
        errtype, value, tback = exc_info
        if all([x is None for x in exc_info]):
            return True
        elif all((isinstance(errtype, TypeType),
                  isinstance(value, Exception),
                  hasattr(tback, 'tb_frame'),
                  hasattr(tback, 'tb_lineno'),
                  hasattr(tback, 'tb_next'))):
            return True
    except (TypeError, ValueError):
        pass
    return False 
开发者ID:airbrake,项目名称:airbrake-python,代码行数:21,代码来源:utils.py

示例8: isType

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def isType( o, t ):
    """
    Test for correct type or correct class::
      isType( o, type_or_class ) -> 1|0

    @param o: object to test
    @type  o: any
    @param t: type OR class
    @type  t: any
    @return: result of test
    @rtype: 1|0
    """
    tt = type(o)
    if tt == types.TypeType:
        return type( o ) == t
    if tt == types.ClassType:
        return isinstance( o, t )
    raise Exception, 'unsupported argument type: %s.' % str(tt)


## to be transferred into Biskit.tools 
开发者ID:graik,项目名称:biskit,代码行数:23,代码来源:SparseArray.py

示例9: _check_type

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def _check_type(self):
        if self.type is None:
            if self.action in self.ALWAYS_TYPED_ACTIONS:
                if self.choices is not None:
                    # The "choices" attribute implies "choice" type.
                    self.type = "choice"
                else:
                    # No type given?  "string" is the most sensible default.
                    self.type = "string"
        else:
            # Allow type objects or builtin type conversion functions
            # (int, str, etc.) as an alternative to their names.  (The
            # complicated check of __builtin__ is only necessary for
            # Python 2.1 and earlier, and is short-circuited by the
            # first check on modern Pythons.)
            import __builtin__
            if ( type(self.type) is types.TypeType or
                 (hasattr(self.type, "__name__") and
                  getattr(__builtin__, self.type.__name__, None) is self.type) ):
                self.type = self.type.__name__

            if self.type == "str":
                self.type = "string"

            if self.type not in self.TYPES:
                raise OptionError("invalid option type: %r" % self.type, self)
            if self.action not in self.TYPED_ACTIONS:
                raise OptionError(
                    "must not supply a type for action %r" % self.action, self) 
开发者ID:glmcdona,项目名称:meddle,代码行数:31,代码来源:optparse.py

示例10: _python_type

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def _python_type(t):
        """returns the type corresponding to a certain Python type"""
        if not isinstance(t, _types.TypeType):
            t = type(t)
        return allTypes[_python_types.get(t, 'object_')] 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:7,代码来源:numerictypes.py

示例11: sort_list

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def sort_list(l, key, reverse=False):
        return l.sort(key=key, reverse=reverse)

# In Python 3.x, all objects are "new style" objects descended from 'type', and
# thus types.ClassType and types.TypeType don't exist anymore.  For
# compatibility, we make sure they still work. 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:8,代码来源:pyversion.py

示例12: is_type

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def is_type(obj, typestr_or_type):
    """is_type(obj, typestr_or_type) verifies if obj is of a certain type. It
    can take strings or actual python types for the second argument, i.e.
    'tuple'<->TupleType. 'all' matches all types.

    TODO: Should be extended for choosing more than one type."""
    if typestr_or_type == "all":
        return True
    if type(typestr_or_type) == types.TypeType:
        test_type = typestr_or_type
    else:
        test_type = typestr2type.get(typestr_or_type, False)
    if test_type:
        return isinstance(obj, test_type)
    return False 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:wildcard.py

示例13: get_classes

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def get_classes(mod, metaclass=None):
    """"""
    if metaclass == None:
        metaclass = tuple([types.TypeType, types.ClassType])
    for i in get_callables(mod):
        if isinstance(i, metaclass):
            yield i 
开发者ID:VillanCh,项目名称:g3ar,代码行数:9,代码来源:inspect_utils.py

示例14: md_class

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def md_class(class_obj):
  """Write markdown documentation for a class.

  Documents public methods. Does not currently document subclasses.

  Args:
    class_obj: a types.TypeType object for the class that should be
      documented.
  Returns:
    A list of markdown-formatted lines.
  """
  content = [md_heading(md_escape(class_obj.__name__), level=2)]
  content.append('')
  if class_obj.__doc__:
    content.extend(md_docstring(class_obj.__doc__))

  def should_doc(name, obj):
    return (isinstance(obj, types.FunctionType)
            and (name.startswith('__') or not name.startswith('_')))

  methods_to_doc = sorted(
      obj for name, obj in class_obj.__dict__.iteritems()
      if should_doc(name, obj))

  for m in methods_to_doc:
    content.extend(md_function(m, class_obj=class_obj))

  return content 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:30,代码来源:markdown.py

示例15: newPizza

# 需要导入模块: import types [as 别名]
# 或者: from types import TypeType [as 别名]
def newPizza(ingredient):
        # Walk through all Pizza classes 
        pizzaClasses = [j for (i,j) in globals().iteritems() if isinstance(j, TypeType) and issubclass(j, Pizza)]
        for pizzaClass in pizzaClasses :
            if pizzaClass.containsIngredient(ingredient):
                return pizzaClass()
        #if research was unsuccessful, raise an error
        raise ValueError('No pizza containing "%s".' % ingredient) 
开发者ID:ActiveState,项目名称:code,代码行数:10,代码来源:recipe-576687.py


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