Python types.MemberDescriptorType() Examples
The following are 30
code examples of types.MemberDescriptorType().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
types
, or try the search function
.
Example #1
Source File: inspect.py From Imogen with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #2
Source File: inspect.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #3
Source File: inspect.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #4
Source File: inspect.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #5
Source File: inspect.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #6
Source File: inspect.py From medicare-demo with Apache License 2.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #7
Source File: inspect.py From unity-python with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #8
Source File: inspect.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #9
Source File: inspect.py From android_universal with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #10
Source File: inspect.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #11
Source File: zombie.py From sidekick with MIT License | 5 votes |
def get_class_slots(cls): """ Return a list of all slots registered in class and parent classes. """ slots = set() for sub in cls.mro(): if sub is object: continue # Get slots from slots attribute cls_slots = sub.__dict__.get("__slots__") if isinstance(cls_slots, str): slots.add(cls_slots) continue elif isinstance(cls_slots, (tuple, list)): slots.update(slots) continue # Explicitly search for slot member objects else: members = [] for k, v in sub.__dict__.items(): if isinstance(v, MemberDescriptorType): members.append(k) if members: slots.update(members) else: return None return tuple(slots)
Example #12
Source File: inspect.py From jawfish with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #13
Source File: inspect.py From ironpython3 with Apache License 2.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #14
Source File: test_descr.py From android_universal with MIT License | 5 votes |
def test_slots_special2(self): # Testing __qualname__ and __classcell__ in __slots__ class Meta(type): def __new__(cls, name, bases, namespace, attr): self.assertIn(attr, namespace) return super().__new__(cls, name, bases, namespace) class C1: def __init__(self): self.b = 42 class C2(C1, metaclass=Meta, attr="__classcell__"): __slots__ = ["__classcell__"] def __init__(self): super().__init__() self.assertIsInstance(C2.__dict__["__classcell__"], types.MemberDescriptorType) c = C2() self.assertEqual(c.b, 42) self.assertNotHasAttr(c, "__classcell__") c.__classcell__ = 42 self.assertEqual(c.__classcell__, 42) with self.assertRaises(TypeError): class C3: __classcell__ = 42 __slots__ = ["__classcell__"] class Q1(metaclass=Meta, attr="__qualname__"): __slots__ = ["__qualname__"] self.assertEqual(Q1.__qualname__, C1.__qualname__[:-2] + "Q1") self.assertIsInstance(Q1.__dict__["__qualname__"], types.MemberDescriptorType) q = Q1() self.assertNotHasAttr(q, "__qualname__") q.__qualname__ = "q" self.assertEqual(q.__qualname__, "q") with self.assertRaises(TypeError): class Q2: __qualname__ = object() __slots__ = ["__qualname__"]
Example #15
Source File: inspect.py From canape with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #16
Source File: inspect.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #17
Source File: utils.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def isNonPrimitiveInstance(x): return isinstance(x,types.InstanceType) or not isinstance(x,(float,int,long,type,tuple,list,dict,bool,unicode,str,buffer,complex,slice,types.NoneType, types.FunctionType,types.LambdaType,types.CodeType,types.GeneratorType, types.ClassType,types.UnboundMethodType,types.MethodType,types.BuiltinFunctionType, types.BuiltinMethodType,types.ModuleType,types.FileType,types.XRangeType, types.TracebackType,types.FrameType,types.EllipsisType,types.DictProxyType, types.NotImplementedType,types.GetSetDescriptorType,types.MemberDescriptorType ))
Example #18
Source File: utils.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def isNonPrimitiveInstance(x): return not isinstance(x,(float,int,type,tuple,list,dict,str,bytes,complex,bool,slice,_rl_NoneType, types.FunctionType,types.LambdaType,types.CodeType, types.MappingProxyType,types.SimpleNamespace, types.GeneratorType,types.MethodType,types.BuiltinFunctionType, types.BuiltinMethodType,types.ModuleType,types.TracebackType, types.FrameType,types.GetSetDescriptorType,types.MemberDescriptorType))
Example #19
Source File: inspect.py From pmatic with GNU General Public License v2.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #20
Source File: inspect.py From oss-ftp with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #21
Source File: inspect.py From Computable with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #22
Source File: inspect.py From BinderFilter with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #23
Source File: inspect.py From ironpython2 with Apache License 2.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #24
Source File: inspect.py From meddle with MIT License | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #25
Source File: inspect.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #26
Source File: inspect.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def ismemberdescriptor(object): """Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.""" return isinstance(object, types.MemberDescriptorType)
Example #27
Source File: jsonobject.py From zstack-utility with Apache License 2.0 | 5 votes |
def _is_unsupported_type(obj): return isinstance(obj, (types.ComplexType, types.TupleType, types.FunctionType, types.LambdaType, types.GeneratorType, types.MethodType, types.UnboundMethodType, types.BuiltinFunctionType, types.BuiltinMethodType, types.FileType, types.XRangeType, types.TracebackType, types.FrameType, types.DictProxyType, types.NotImplementedType, types.GetSetDescriptorType, types.MemberDescriptorType))
Example #28
Source File: inspect.py From python-hunter with BSD 2-Clause "Simplified" License | 4 votes |
def getattr_static(obj, attr, default=_sentinel): """Retrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. """ instance_result = _sentinel if not _is_type(obj): klass = _get_type(obj) dict_attr = _shadowed_dict(klass) if dict_attr is _sentinel or type(dict_attr) is types.MemberDescriptorType: # noqa instance_result = _check_instance(obj, attr) else: klass = obj klass_result = _check_class(klass, attr) if instance_result is not _sentinel and klass_result is not _sentinel: if _safe_hasattr(klass_result, '__get__') and _safe_is_data_descriptor(klass_result): return klass_result if instance_result is not _sentinel: return instance_result if klass_result is not _sentinel: return klass_result if obj is klass: # for types we check the metaclass too for entry in _static_getmro(type(klass)): if _shadowed_dict(type(entry)) is _sentinel: try: return entry.__dict__[attr] except KeyError: pass if default is not _sentinel: return default raise AttributeError(attr)
Example #29
Source File: inspect.py From android_universal with MIT License | 4 votes |
def getattr_static(obj, attr, default=_sentinel): """Retrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. """ instance_result = _sentinel if not _is_type(obj): klass = type(obj) dict_attr = _shadowed_dict(klass) if (dict_attr is _sentinel or type(dict_attr) is types.MemberDescriptorType): instance_result = _check_instance(obj, attr) else: klass = obj klass_result = _check_class(klass, attr) if instance_result is not _sentinel and klass_result is not _sentinel: if (_check_class(type(klass_result), '__get__') is not _sentinel and _check_class(type(klass_result), '__set__') is not _sentinel): return klass_result if instance_result is not _sentinel: return instance_result if klass_result is not _sentinel: return klass_result if obj is klass: # for types we check the metaclass too for entry in _static_getmro(type(klass)): if _shadowed_dict(type(entry)) is _sentinel: try: return entry.__dict__[attr] except KeyError: pass if default is not _sentinel: return default raise AttributeError(attr) # ------------------------------------------------ generator introspection
Example #30
Source File: inspect.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def getattr_static(obj, attr, default=_sentinel): """Retrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. """ instance_result = _sentinel if not _is_type(obj): klass = type(obj) dict_attr = _shadowed_dict(klass) if (dict_attr is _sentinel or type(dict_attr) is types.MemberDescriptorType): instance_result = _check_instance(obj, attr) else: klass = obj klass_result = _check_class(klass, attr) if instance_result is not _sentinel and klass_result is not _sentinel: if (_check_class(type(klass_result), '__get__') is not _sentinel and _check_class(type(klass_result), '__set__') is not _sentinel): return klass_result if instance_result is not _sentinel: return instance_result if klass_result is not _sentinel: return klass_result if obj is klass: # for types we check the metaclass too for entry in _static_getmro(type(klass)): if _shadowed_dict(type(entry)) is _sentinel: try: return entry.__dict__[attr] except KeyError: pass if default is not _sentinel: return default raise AttributeError(attr) # ------------------------------------------------ generator introspection