Ability to specify defines_by_path during command line invocation 1.5
authorSergey Matveev <stargrave@stargrave.org>
Mon, 6 Nov 2017 08:45:46 +0000 (11:45 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 6 Nov 2017 08:46:12 +0000 (11:46 +0300)
VERSION
doc/news.rst
pyderasn.py

diff --git a/VERSION b/VERSION
index c068b2447cc22327bcac3f4884de3b32025c5bb2..c239c60cba28a79a295acb60a122b8c46eb57271 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.4
+1.5
index 24cec4eb303644d7ae7833e796f7641439e582a5..10023113a8d31aa27c72016958fd8102f761c128 100644 (file)
@@ -7,6 +7,8 @@ News
 ---
 * Generic decoder's scheme and pretty printer
   (:py:func:`pyderasn.generic_decoder`) can be used in libraries.
 ---
 * Generic decoder's scheme and pretty printer
   (:py:func:`pyderasn.generic_decoder`) can be used in libraries.
+* Ability to specify :ref:`defines_by_path <defines_by_path_kwarg>`
+  during command line invocation.
 
 .. _release1.4:
 
 
 .. _release1.4:
 
index 717c06cce42d63a15ed38356f71eb92cce217076..6d1e7eb736235ec29d37853a0b418525a2e16599 100755 (executable)
@@ -261,6 +261,8 @@ defined, ``value`` contains corresponding decoded value. For example
 above, ``content_info["content"].defined == (id_signedData,
 signed_data)``.
 
 above, ``content_info["content"].defined == (id_signedData,
 signed_data)``.
 
+.. _defines_by_path_kwarg:
+
 defines_by_path kwarg
 _____________________
 
 defines_by_path kwarg
 _____________________
 
@@ -4334,6 +4336,10 @@ def main():  # pragma: no cover
         "--schema",
         help="Python path to schema definition to use",
     )
         "--schema",
         help="Python path to schema definition to use",
     )
+    parser.add_argument(
+        "--defines-by-path",
+        help="Python path to decoder's defines_by_path",
+    )
     parser.add_argument(
         "DERFile",
         type=argparse.FileType("rb"),
     parser.add_argument(
         "DERFile",
         type=argparse.FileType("rb"),
@@ -4349,7 +4355,13 @@ def main():  # pragma: no cover
         pprinter = partial(pprint, big_blobs=True)
     else:
         schema, pprinter = generic_decoder()
         pprinter = partial(pprint, big_blobs=True)
     else:
         schema, pprinter = generic_decoder()
-    obj, tail = schema().decode(der)
+    obj, tail = schema().decode(
+        der,
+        defines_by_path=(
+            None if args.defines_by_path is None
+            else obj_by_path(args.defines_by_path)
+        ),
+    )
     print(pprinter(obj, oids=oids))
     if tail != b"":
         print("\nTrailing data: %s" % hexenc(tail))
     print(pprinter(obj, oids=oids))
     if tail != b"":
         print("\nTrailing data: %s" % hexenc(tail))