MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / isValue

Method isValue

pager_lib/pyasn1/type/univ.py:2630–2685  ·  view source on GitHub ↗

Indicate that |ASN.1| object represents ASN.1 value. If *isValue* is :obj:`False` then this object represents just ASN.1 schema. If *isValue* is :obj:`True` then, in addition to its ASN.1 schema features, this object can also be used like a Python built-in object (e.g.

(self)

Source from the content-addressed store, hash-verified

2628
2629 @property
2630 def isValue(self):
2631 """Indicate that |ASN.1| object represents ASN.1 value.
2632
2633 If *isValue* is :obj:`False` then this object represents just ASN.1 schema.
2634
2635 If *isValue* is :obj:`True` then, in addition to its ASN.1 schema features,
2636 this object can also be used like a Python built-in object (e.g.
2637 :class:`int`, :class:`str`, :class:`dict` etc.).
2638
2639 Returns
2640 -------
2641 : :class:`bool`
2642 :obj:`False` if object represents just ASN.1 schema.
2643 :obj:`True` if object represents ASN.1 schema and can be used as a
2644 normal value.
2645
2646 Note
2647 ----
2648 There is an important distinction between PyASN1 schema and value objects.
2649 The PyASN1 schema objects can only participate in ASN.1 schema-related
2650 operations (e.g. defining or testing the structure of the data). Most
2651 obvious uses of ASN.1 schema is to guide serialisation codecs whilst
2652 encoding/decoding serialised ASN.1 contents.
2653
2654 The PyASN1 value objects can **additionally** participate in many operations
2655 involving regular Python objects (e.g. arithmetic, comprehension etc).
2656
2657 It is sufficient for |ASN.1| objects to have all non-optional and non-defaulted
2658 components being value objects to be considered as a value objects as a whole.
2659 In other words, even having one or more optional components not turned into
2660 value objects, |ASN.1| object is still considered as a value object. Defaulted
2661 components are normally value objects by default.
2662 """
2663 if self._componentValues is noValue:
2664 return False
2665
2666 componentType = self.componentType
2667
2668 if componentType:
2669 for idx, subComponentType in enumerate(componentType.namedTypes):
2670 if subComponentType.isDefaulted or subComponentType.isOptional:
2671 continue
2672
2673 if not self._componentValues:
2674 return False
2675
2676 componentValue = self._componentValues[idx]
2677 if componentValue is noValue or not componentValue.isValue:
2678 return False
2679
2680 else:
2681 for componentValue in self._componentValues:
2682 if componentValue is noValue or not componentValue.isValue:
2683 return False
2684
2685 return True
2686
2687 @property

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected