summaryrefslogtreecommitdiff
path: root/pyasn1/codec/cer/encoder.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-07-31 11:05:18 +0200
committerIlya Etingof <etingof@gmail.com>2017-07-31 11:05:18 +0200
commit3e6a176073cc9c1724efeb76255e988f221ad08a (patch)
treea1e87227fd46c44f57f1fd677eef64cf419c4be0 /pyasn1/codec/cer/encoder.py
parent6fa0e312ea80713983b1a3c1e4529e7452b0e0fe (diff)
downloadpyasn1-git-3e6a176073cc9c1724efeb76255e988f221ad08a.tar.gz
better parameter name for encoders
Diffstat (limited to 'pyasn1/codec/cer/encoder.py')
-rw-r--r--pyasn1/codec/cer/encoder.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/pyasn1/codec/cer/encoder.py b/pyasn1/codec/cer/encoder.py
index 39f7c09..e99e0b1 100644
--- a/pyasn1/codec/cer/encoder.py
+++ b/pyasn1/codec/cer/encoder.py
@@ -14,8 +14,8 @@ __all__ = ['encode']
class BooleanEncoder(encoder.IntegerEncoder):
- def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
- if client == 0:
+ def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
+ if value == 0:
substrate = (0,)
else:
substrate = (255,)
@@ -23,16 +23,16 @@ class BooleanEncoder(encoder.IntegerEncoder):
class BitStringEncoder(encoder.BitStringEncoder):
- def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
+ def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
return encoder.BitStringEncoder.encodeValue(
- self, encodeFun, client, defMode, 1000
+ self, encodeFun, value, defMode, 1000
)
class OctetStringEncoder(encoder.OctetStringEncoder):
- def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
+ def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
return encoder.OctetStringEncoder.encodeValue(
- self, encodeFun, client, defMode, 1000
+ self, encodeFun, value, defMode, 1000
)
@@ -52,7 +52,7 @@ class TimeEncoderMixIn(object):
minLength = 12
maxLength = 19
- def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
+ def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
# Encoding constraints:
# - minutes are mandatory, seconds are optional
# - subseconds must NOT be zero
@@ -60,10 +60,10 @@ class TimeEncoderMixIn(object):
# - time in UTC (Z)
# - only dot is allowed for fractions
- octets = client.asOctets()
+ octets = value.asOctets()
if not self.minLength < len(octets) < self.maxLength:
- raise error.PyAsn1Error('Length constraint violated: %r' % client)
+ raise error.PyAsn1Error('Length constraint violated: %r' % value)
if self.pluschar in octets or self.minuschar in octets:
raise error.PyAsn1Error('Must be UTC time: %r' % octets)
@@ -72,10 +72,10 @@ class TimeEncoderMixIn(object):
raise error.PyAsn1Error('Missing "Z" time zone specifier: %r' % octets)
if self.commachar in octets:
- raise error.PyAsn1Error('Comma in fractions disallowed: %r' % client)
+ raise error.PyAsn1Error('Comma in fractions disallowed: %r' % value)
return encoder.OctetStringEncoder.encodeValue(
- self, encodeFun, client, defMode, 1000
+ self, encodeFun, value, defMode, 1000
)
@@ -95,27 +95,27 @@ class SetOfEncoder(encoder.SequenceOfEncoder):
# sort by tags regardless of the Choice value (static sort)
return sorted(components, key=lambda x: isinstance(x, univ.Choice) and x.minTagSet or x.tagSet)
- def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
- client.verifySizeSpec()
+ def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
+ value.verifySizeSpec()
substrate = null
- idx = len(client)
+ 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(client, univ.SequenceAndSetBase):
+ if isinstance(value, univ.SequenceAndSetBase):
# Set
- namedTypes = client.componentType
+ namedTypes = value.componentType
comps = []
compsMap = {}
while idx > 0:
idx -= 1
if namedTypes:
- if namedTypes[idx].isOptional and not client[idx].isValue:
+ if namedTypes[idx].isOptional and not value[idx].isValue:
continue
- if namedTypes[idx].isDefaulted and client[idx] == namedTypes[idx].asn1Object:
+ if namedTypes[idx].isDefaulted and value[idx] == namedTypes[idx].asn1Object:
continue
- comps.append(client[idx])
- compsMap[id(client[idx])] = namedTypes[idx].isOptional
+ comps.append(value[idx])
+ compsMap[id(value[idx])] = namedTypes[idx].isOptional
for comp in self._sortComponents(comps):
substrate += encodeFun(comp, defMode, maxChunkSize, compsMap[id(comp)])
@@ -125,7 +125,7 @@ class SetOfEncoder(encoder.SequenceOfEncoder):
while idx > 0:
idx -= 1
compSubs.append(
- encodeFun(client[idx], defMode, maxChunkSize)
+ encodeFun(value[idx], defMode, maxChunkSize)
)
compSubs.sort() # perhaps padding's not needed
substrate = null
@@ -182,8 +182,8 @@ typeMap.update({
class Encoder(encoder.Encoder):
- def __call__(self, client, defMode=False, maxChunkSize=0, isOptional=False):
- return encoder.Encoder.__call__(self, client, defMode, maxChunkSize, isOptional)
+ def __call__(self, value, defMode=False, maxChunkSize=0, isOptional=False):
+ return encoder.Encoder.__call__(self, value, defMode, maxChunkSize, isOptional)
#: Turns ASN.1 object into CER octet stream.