本文整理汇总了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
示例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))
示例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))
示例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))
示例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))
示例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
示例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
示例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
示例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)
示例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_')]
示例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.
示例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
示例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
示例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
示例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)