我们从Python开源项目中,提取了以下31个代码示例,用于说明如何使用pyasn1.type.univ.SequenceAndSetBase()。
def encodeValue(self, encodeFun, client, defMode, maxChunkSize): if isinstance(client, univ.SequenceAndSetBase): client.setDefaultComponents() client.verifySizeSpec() substrate = null; idx = len(client) # This is certainly a hack but how else do I distinguish SetOf # from Set if they have the same tags&constraints? if isinstance(client, univ.SequenceAndSetBase): # Set comps = [] while idx > 0: idx = idx - 1 if client[idx] is None: # Optional component continue if client.getDefaultComponentByPosition(idx) == client[idx]: continue comps.append(client[idx]) comps.sort(key=lambda x: isinstance(x, univ.Choice) and \ x.getMinTagSet() or x.getTagSet()) for c in comps: substrate += encodeFun(c, defMode, maxChunkSize) else: # SetOf compSubs = [] while idx > 0: idx = idx - 1 compSubs.append( encodeFun(client[idx], defMode, maxChunkSize) ) compSubs.sort() # perhaps padding's not needed substrate = null for compSub in compSubs: substrate += compSub return substrate, 1
def encodeValue(self, encodeFun, value, defMode, maxChunkSize, ifNotEmpty=False): value.verifySizeSpec() substrate = null idx = len(value) # This is certainly a hack but how else do I distinguish SetOf # from Set if they have the same tags&constraints? if isinstance(value, univ.SequenceAndSetBase): # Set namedTypes = value.componentType comps = [] compsMap = {} while idx > 0: idx -= 1 if namedTypes: if namedTypes[idx].isOptional and not value[idx].isValue: continue if namedTypes[idx].isDefaulted and value[idx] == namedTypes[idx].asn1Object: continue comps.append(value[idx]) compsMap[id(value[idx])] = namedTypes[idx].isOptional for comp in self._sortComponents(comps): substrate += encodeFun(comp, defMode, maxChunkSize, ifNotEmpty=compsMap[id(comp)]) else: # SetOf compSubs = [] while idx > 0: idx -= 1 compSubs.append( encodeFun(value[idx], defMode, maxChunkSize) ) compSubs.sort() # perhaps padding's not needed substrate = null for compSub in compSubs: substrate += compSub return substrate, True, True
def encodeValue(self, encodeFun, client, defMode, maxChunkSize): if isinstance(client, univ.SequenceAndSetBase): client.setDefaultComponents() client.verifySizeSpec() substrate = null idx = len(client) # This is certainly a hack but how else do I distinguish SetOf # from Set if they have the same tags&constraints? if isinstance(client, univ.SequenceAndSetBase): # Set comps = [] while idx > 0: idx -= 1 if client[idx] is None: # Optional component continue if client.getDefaultComponentByPosition(idx) == client[idx]: continue comps.append(client[idx]) comps.sort(key=lambda x: isinstance(x, univ.Choice) and x.getMinTagSet() or x.getTagSet()) for c in comps: substrate += encodeFun(c, defMode, maxChunkSize) else: # SetOf compSubs = [] while idx > 0: idx -= 1 compSubs.append( encodeFun(client[idx], defMode, maxChunkSize) ) compSubs.sort() # perhaps padding's not needed substrate = null for compSub in compSubs: substrate += compSub return substrate, 1