From fe74d84a4e492c8ce88b94b18f55b8f264e3de23 Mon Sep 17 00:00:00 2001 From: nick <184579+nmpowell@users.noreply.github.com> Date: Thu, 25 Feb 2021 09:41:38 +0000 Subject: [PATCH 1/2] accept custom config path in Phab constructor --- phabricator/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/phabricator/__init__.py b/phabricator/__init__.py index 6d53748..3df36fc 100644 --- a/phabricator/__init__.py +++ b/phabricator/__init__.py @@ -45,6 +45,7 @@ # Load arc config +ARCRC = {} ARC_CONFIGS = ( # System config os.path.join( @@ -67,13 +68,19 @@ os.path.join(CURRENT_DIR, '.git', 'arc', 'config'), ) -ARCRC = {} -for conf in ARC_CONFIGS: - if os.path.exists(conf): - with open(conf, 'r') as fobj: + +def update_arcrc(config_path=""): + """Read a config file as JSON and update ARCRC. + """ + if config_path and os.path.exists(config_path): + with open(config_path, 'r') as fobj: ARCRC.update(json.load(fobj)) +for config in ARC_CONFIGS: + update_arcrc(config) + + # Map Phabricator types to Python types PARAM_TYPE_MAP = { # int types @@ -332,9 +339,10 @@ class Phabricator(Resource): 'json': lambda x: json.loads(x), } - def __init__(self, username=None, certificate=None, host=None, - timeout=5, response_format='json', token=None, **kwargs): + def __init__(self, username=None, certificate=None, host=None, timeout=5, + response_format='json', token=None, config_path=None, **kwargs): + update_arcrc(config_path) defined_hosts = ARCRC.get('hosts', {}) try: From 4ae46e155c72bfdb96cac3188b3e47da89fcdb5f Mon Sep 17 00:00:00 2001 From: nick <184579+nmpowell@users.noreply.github.com> Date: Thu, 25 Feb 2021 09:55:32 +0000 Subject: [PATCH 2/2] required argument --- phabricator/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phabricator/__init__.py b/phabricator/__init__.py index 3df36fc..dc35c14 100644 --- a/phabricator/__init__.py +++ b/phabricator/__init__.py @@ -69,7 +69,7 @@ ) -def update_arcrc(config_path=""): +def update_arcrc(config_path): """Read a config file as JSON and update ARCRC. """ if config_path and os.path.exists(config_path):