Skip to content

Commit

Permalink
feat(MultiSign): allow passing multiple contexts through command line…
Browse files Browse the repository at this point in the history
… param
  • Loading branch information
lemoustachiste committed Jun 22, 2022
1 parent fb6f1ba commit 0f0a3be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions cert_issuer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,19 @@ def add_arguments(p):
type=str,
help='When trying to sign a document with an unsupported context, ' +
'provide the url and the path to the local context file.' +
'Comma separated list, must be used in conjunction with the `--context_file_paths` property.',
env_var='CONTEXT_URLS'
'Space separated list, must be used in conjunction with the `--context_file_paths` property.',
env_var='CONTEXT_URLS',
nargs='+'
)
p.add_argument('--context_file_paths',
default=None,
type=str,
help='When trying to sign a document with an unsupported context, ' +
'provide the url and the path to the local context file. ' +
'Comma separated list, must be used in conjunction with the `--context_urls` property. ' +
'Path should be relative to CWD',
env_var='CONTEXT_FILE_PATHS'
'Space separated list, must be used in conjunction with the `--context_urls` property. ' +
'Path should be relative to CWD, order should match `--context_urls` order.',
env_var='CONTEXT_FILE_PATHS',
nargs='+'
)


Expand Down
11 changes: 6 additions & 5 deletions cert_issuer/normalization_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def normalize_to_utf8(certificate_json):

@staticmethod
def preload_contexts():
print(CONFIG.context_urls, CONFIG.context_file_paths, os.getcwd())
with open(os.path.join(os.getcwd(), CONFIG.context_file_paths)) as context_file:
context_data = json.load(context_file)
print(context_data)
extend_preloaded_context(CONFIG.context_urls, context_data)
if CONFIG.context_urls is None or CONFIG.context_file_paths is None:
return
for (url, path) in zip(CONFIG.context_urls, CONFIG.context_file_paths):
with open(os.path.join(os.getcwd(), path)) as context_file:
context_data = json.load(context_file)
extend_preloaded_context(url, context_data)

0 comments on commit 0f0a3be

Please sign in to comment.