1
1
import os
2
- from typing import Dict , List
2
+ from typing import Dict , List , Optional
3
3
import urllib .request
4
+ import urllib .error
4
5
5
6
6
7
INDY_NETWORKS_GITHUB_RAW_BASE = (
7
- "https://raw.githubusercontent.com/IDunion /indy-did-networks/main"
8
+ "https://raw.githubusercontent.com/hyperledger /indy-did-networks/main"
8
9
)
9
10
GENESIS_FILENAME = "pool_transactions_genesis.json"
10
11
11
12
12
13
def get_genesis_txns_from_did_indy_folder (
13
- path : str , genesis_filename : str = None
14
+ path : str , genesis_filename : Optional [ str ] = None
14
15
) -> Dict [str , str ]:
15
16
"""Retrieves mapping from local folder.
16
17
@@ -40,7 +41,7 @@ def get_genesis_txns_from_did_indy_folder(
40
41
sub_entries = os .listdir (os .path .join (path , entry ))
41
42
42
43
for sub_entry in sub_entries :
43
-
44
+
44
45
sub_entry_p = os .path .join (entry_p , sub_entry )
45
46
sub_namespace = sub_entry if os .path .isdir (sub_entry_p ) else None
46
47
@@ -57,12 +58,15 @@ def get_genesis_txns_from_did_indy_folder(
57
58
58
59
59
60
def get_genesis_txns_from_did_indy_repo_by_name (
60
- namespaces : List [str ], genesis_filename : str = None
61
+ namespaces : List [str ], genesis_filename : Optional [str ] = None ,
62
+ * ,
63
+ repo_base_url : Optional [str ] = None ,
61
64
) -> Dict [str , str ]:
62
65
"""Retrieves genesis txn from standard indy networks repo given their names."""
63
66
genesis_map = dict ()
64
67
65
68
genesis_filename = genesis_filename if genesis_filename else GENESIS_FILENAME
69
+ repo_base_url = repo_base_url or INDY_NETWORKS_GITHUB_RAW_BASE
66
70
67
71
base_dir = "networks"
68
72
@@ -73,7 +77,7 @@ def get_genesis_txns_from_did_indy_repo_by_name(
73
77
main = next (parts , None )
74
78
sub = next (parts , None )
75
79
76
- genesis_file_url = f"{ INDY_NETWORKS_GITHUB_RAW_BASE } /networks/{ name } /{ genesis_filename } "
80
+ genesis_file_url = f"{ repo_base_url } /networks/{ name } /{ genesis_filename } "
77
81
target_local_path = f"{ base_dir } /{ name } /{ genesis_filename } "
78
82
try :
79
83
urllib .request .urlretrieve (genesis_file_url , target_local_path )
0 commit comments