diff --git a/phabricator/__init__.py b/phabricator/__init__.py index 6d53748..dc35c14 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: