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

Class SetEncoder

pager_lib/pyasn1/codec/der/encoder.py:16–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class SetEncoder(encoder.SetEncoder):
17 @staticmethod
18 def _componentSortKey(componentAndType):
19 """Sort SET components by tag
20
21 Sort depending on the actual Choice value (dynamic sort)
22 """
23 component, asn1Spec = componentAndType
24
25 if asn1Spec is None:
26 compType = component
27 else:
28 compType = asn1Spec
29
30 if compType.typeId == univ.Choice.typeId and not compType.tagSet:
31 if asn1Spec is None:
32 return component.getComponent().tagSet
33 else:
34 # TODO: move out of sorting key function
35 names = [namedType.name for namedType in asn1Spec.componentType.namedTypes
36 if namedType.name in component]
37 if len(names) != 1:
38 raise error.PyAsn1Error(
39 '%s components for Choice at %r' % (len(names) and 'Multiple ' or 'None ', component))
40
41 # TODO: support nested CHOICE ordering
42 return asn1Spec[names[0]].tagSet
43
44 else:
45 return compType.tagSet
46
47
48TAG_MAP = encoder.TAG_MAP.copy()

Callers 1

encoder.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected