From 2fc01cf384f1ee20e95e5531c37d350ebea67ee5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 9 Oct 2017 11:58:44 +0300 Subject: [PATCH] Replace some branches with if/else operator --- pyderasn.py | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/pyderasn.py b/pyderasn.py index d14997b..e3eec94 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -688,10 +688,7 @@ class Obj(object): optional=False, _decoded=(0, 0, 0), ): - if impl is None: - self.tag = getattr(self, "impl", self.tag_default) - else: - self.tag = impl + self.tag = getattr(self, "impl", self.tag_default) if impl is None else impl self._expl = getattr(self, "expl", None) if expl is None else expl if self.tag != self.tag_default and self._expl is not None: raise ValueError( @@ -1261,14 +1258,11 @@ class Integer(Obj): self._value = value specs = getattr(self, "schema", {}) if _specs is None else _specs self.specs = specs if isinstance(specs, dict) else dict(specs) - if bounds is None: - self._bound_min, self._bound_max = getattr( - self, - "bounds", - (float("-inf"), float("+inf")), - ) - else: - self._bound_min, self._bound_max = bounds + self._bound_min, self._bound_max = getattr( + self, + "bounds", + (float("-inf"), float("+inf")), + ) if bounds is None else bounds if value is not None: self._value = self._value_sanitize(value) if default is not None: @@ -1894,14 +1888,11 @@ class OctetString(Obj): _decoded, ) self._value = value - if bounds is None: - self._bound_min, self._bound_max = getattr( - self, - "bounds", - (0, float("+inf")), - ) - else: - self._bound_min, self._bound_max = bounds + self._bound_min, self._bound_max = getattr( + self, + "bounds", + (0, float("+inf")), + ) if bounds is None else bounds if value is not None: self._value = self._value_sanitize(value) if default is not None: @@ -3824,14 +3815,11 @@ class SequenceOf(Obj): if schema is None: raise ValueError("schema must be specified") self.spec = schema - if bounds is None: - self._bound_min, self._bound_max = getattr( - self, - "bounds", - (0, float("+inf")), - ) - else: - self._bound_min, self._bound_max = bounds + self._bound_min, self._bound_max = getattr( + self, + "bounds", + (0, float("+inf")), + ) if bounds is None else bounds self._value = [] if value is not None: self._value = self._value_sanitize(value) -- 2.44.0