aboutsummaryrefslogtreecommitdiff
path: root/pyasn1/type
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-08-23 18:50:47 +0200
committerIlya Etingof <etingof@gmail.com>2017-08-23 18:50:47 +0200
commit748429c2a4c3a960fe009da67421e20b27086a86 (patch)
tree249d8327ab0a980303bae9f46e1d126f0a6d54b6 /pyasn1/type
parentfcfbd153ccb98826e305dee1c057fb15d63754bc (diff)
downloadpyasn1-748429c2a4c3a960fe009da67421e20b27086a86.tar.gz
replaced range(len()) with enumerate() at a few places
Diffstat (limited to 'pyasn1/type')
-rw-r--r--pyasn1/type/univ.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index 956d06b..67d8b14 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -1881,13 +1881,13 @@ class SequenceOfAndSetOfBase(base.AbstractConstructedAsn1Item):
def prettyPrint(self, scope=0):
scope += 1
representation = self.__class__.__name__ + ':\n'
- for idx in range(len(self._componentValues)):
+ for idx, componentValue in enumerate(self._componentValues):
representation += ' ' * scope
- if (self._componentValues[idx] is noValue and
+ if (componentValue is noValue and
self.componentType is not None):
representation += '<empty>'
else:
- representation += self._componentValues[idx].prettyPrint(scope)
+ representation += componentValue.prettyPrint(scope)
return representation
def prettyPrintType(self, scope=0):
@@ -2291,23 +2291,23 @@ class SequenceAndSetBase(base.AbstractConstructedAsn1Item):
"""
scope += 1
representation = self.__class__.__name__ + ':\n'
- for idx in range(len(self._componentValues)):
- if self._componentValues[idx] is not noValue:
+ for idx, componentValue in enumerate(self._componentValues):
+ if componentValue is not noValue:
representation += ' ' * scope
representation += self.componentType.getNameByPosition(idx)
representation = '%s=%s\n' % (
- representation, self._componentValues[idx].prettyPrint(scope)
+ representation, componentValue.prettyPrint(scope)
)
return representation
def prettyPrintType(self, scope=0):
scope += 1
representation = '%s -> %s {\n' % (self.tagSet, self.__class__.__name__)
- for idx in range(len(self.componentType)):
+ for idx, componentType in enumerate(self.componentType):
representation += ' ' * scope
representation += '"%s"' % self.componentType.getNameByPosition(idx)
representation = '%s = %s\n' % (
- representation, self.componentType.getTypeByPosition(idx).prettyPrintType(scope)
+ representation, componentType.prettyPrintType(scope)
)
return representation + '\n' + ' ' * (scope - 1) + '}'