]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - pyderasn.py
Grammar typos
[pyderasn.git] / pyderasn.py
index abb5be5fd83f8482d9268295c833a1f5ee3230bb..5adc5b068d17915f0c543144b66557b9fc355f30 100755 (executable)
@@ -1179,6 +1179,11 @@ class Obj(object):
             return raw
         return b"".join((self._expl, len_encode(len(raw)), raw))
 
+    def hexencode(self):
+        """Do hexadecimal encoded :py:meth:`pyderasn.Obj.encode`
+        """
+        return hexenc(self.encode())
+
     def decode(
             self,
             data,
@@ -1323,6 +1328,16 @@ class Obj(object):
             raise ExceedingData(len(tail))
         return obj
 
+    def hexdecode(self, data, *args, **kwargs):
+        """Do :py:meth:`pyderasn.Obj.decode` with hexadecimal decoded data
+        """
+        return self.decode(hexdec(data), *args, **kwargs)
+
+    def hexdecod(self, data, *args, **kwargs):
+        """Do :py:meth:`pyderasn.Obj.decod` with hexadecimal decoded data
+        """
+        return self.decod(hexdec(data), *args, **kwargs)
+
     @property
     def expled(self):
         """See :ref:`decoding`
@@ -1654,9 +1669,8 @@ def pprint(
     """Pretty print object
 
     :param Obj obj: object you want to pretty print
-    :param oid_maps: list of ``OID <-> humand readable string`` dictionary.
-                     When OID from it is met, then its humand readable form
-                     is printed
+    :param oid_maps: list of ``str(OID) <-> human readable string`` dictionary.
+                     Its human readable form is printed when OID is met
     :param big_blobs: if large binary objects are met (like OctetString
                       values), do we need to print them too, on separate
                       lines
@@ -3991,6 +4005,10 @@ class PrintableString(AllowableCharsMixin, CommonString):
 
     >>> PrintableString().allowable_chars
     frozenset([' ', "'", ..., 'z'])
+    >>> obj = PrintableString("foo*bar", allow_asterisk=True)
+    PrintableString PrintableString foo*bar
+    >>> obj.allow_asterisk, obj.allow_ampersand
+    (True, False)
     """
     __slots__ = ()
     tag_default = tag_encode(19)
@@ -4026,6 +4044,18 @@ class PrintableString(AllowableCharsMixin, CommonString):
             value, bounds, impl, expl, default, optional, _decoded,
         )
 
+    @property
+    def allow_asterisk(self):
+        """Is asterisk character allowed?
+        """
+        return self._asterisk <= self._allowable_chars
+
+    @property
+    def allow_ampersand(self):
+        """Is ampersand character allowed?
+        """
+        return self._ampersand <= self._allowable_chars
+
     def _value_sanitize(self, value):
         value = super(PrintableString, self)._value_sanitize(value)
         if not frozenset(value) <= self._allowable_chars:
@@ -4061,8 +4091,8 @@ class PrintableString(AllowableCharsMixin, CommonString):
             expl=self._expl if expl is None else expl,
             default=self.default if default is None else default,
             optional=self.optional if optional is None else optional,
-            allow_asterisk=self._asterisk <= self._allowable_chars,
-            allow_ampersand=self._ampersand <= self._allowable_chars,
+            allow_asterisk=self.allow_asterisk,
+            allow_ampersand=self.allow_ampersand,
         )
 
 
@@ -4270,6 +4300,10 @@ class GeneralizedTime(UTCTime):
        Only microsecond fractions are supported.
        :py:exc:`pyderasn.DecodeError` will be raised during decoding of
        higher precision values.
+
+    .. warning::
+
+       Zero year is unsupported.
     """
     __slots__ = ()
     tag_default = tag_encode(24)
@@ -4278,7 +4312,7 @@ class GeneralizedTime(UTCTime):
     def _strptime(self, value):
         l = len(value)
         if l == LEN_YYYYMMDDHHMMSSZ:
-            # datetime.strptime's format: %y%m%d%H%M%SZ
+            # datetime.strptime's format: %Y%m%d%H%M%SZ
             if value[-1] != "Z":
                 raise ValueError("non UTC timezone")
             return datetime(