From 3485617cd8e158154eae89c0ef2258e7528e2b3b Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 6 Nov 2017 11:45:46 +0300 Subject: [PATCH] Ability to specify defines_by_path during command line invocation --- VERSION | 2 +- doc/news.rst | 2 ++ pyderasn.py | 14 +++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index c068b24..c239c60 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4 +1.5 diff --git a/doc/news.rst b/doc/news.rst index 24cec4e..1002311 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -7,6 +7,8 @@ News --- * Generic decoder's scheme and pretty printer (:py:func:`pyderasn.generic_decoder`) can be used in libraries. +* Ability to specify :ref:`defines_by_path ` + during command line invocation. .. _release1.4: diff --git a/pyderasn.py b/pyderasn.py index 717c06c..6d1e7eb 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -261,6 +261,8 @@ defined, ``value`` contains corresponding decoded value. For example above, ``content_info["content"].defined == (id_signedData, signed_data)``. +.. _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", ) + parser.add_argument( + "--defines-by-path", + help="Python path to decoder's defines_by_path", + ) 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() - 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)) -- 2.44.0