|
31 | 31 | __all__ = ['Phabricator']
|
32 | 32 |
|
33 | 33 |
|
34 |
| -# Default phabricator interfaces |
35 |
| -INTERFACES = json.loads(open(os.path.join(os.path.dirname(__file__), 'interfaces.json'), 'r').read()) |
| 34 | +ON_WINDOWS = os.name == 'nt' |
| 35 | +CURRENT_DIR = os.getcwd() |
| 36 | + |
| 37 | + |
| 38 | +# Default Phabricator interfaces |
| 39 | +INTERFACES = {} |
| 40 | +with open(os.path.join(os.path.dirname(__file__), 'interfaces.json')) as fobj: |
| 41 | + INTERFACES = json.load(fobj) |
| 42 | + |
36 | 43 |
|
37 | 44 | # Load arc config
|
38 |
| -ARC_CONFIGS = [ |
| 45 | +ARC_CONFIGS = ( |
39 | 46 | # System config
|
40 |
| - os.path.join(os.environ['ProgramData'], 'Phabricator', 'Arcanist', 'config') if os.name == 'nt' else |
41 |
| - os.path.join('/etc', 'arcconfig'), |
| 47 | + os.path.join( |
| 48 | + os.environ['ProgramData'], |
| 49 | + 'Phabricator', |
| 50 | + 'Arcanist', |
| 51 | + 'config' |
| 52 | + ) if ON_WINDOWS else os.path.join('/etc', 'arcconfig'), |
42 | 53 |
|
43 | 54 | # User config
|
44 |
| - os.path.join(os.environ['AppData'] if os.name == 'nt' else os.path.expanduser('~'), '.arcrc'), |
| 55 | + os.path.join( |
| 56 | + os.environ['AppData'] if ON_WINDOWS else os.path.expanduser('~'), |
| 57 | + '.arcrc' |
| 58 | + ), |
45 | 59 |
|
46 | 60 | # Project config
|
47 |
| - os.path.join(os.getcwd(), '.arcconfig'), |
| 61 | + os.path.join(CURRENT_DIR, '.arcconfig'), |
48 | 62 |
|
49 | 63 | # Local project config
|
50 |
| - os.path.join(os.getcwd(), '.git', 'arc', 'config'), |
51 |
| -] |
| 64 | + os.path.join(CURRENT_DIR, '.git', 'arc', 'config'), |
| 65 | +) |
52 | 66 |
|
53 | 67 | ARCRC = {}
|
54 | 68 | for conf in ARC_CONFIGS:
|
55 | 69 | if os.path.exists(conf):
|
56 |
| - ARCRC.update(json.load(open(conf, 'r'))) |
| 70 | + with open(conf, 'r') as fobj: |
| 71 | + ARCRC.update(json.load(fobj)) |
| 72 | + |
57 | 73 |
|
58 | 74 | # Map Phabricator types to Python types
|
59 | 75 | PARAM_TYPE_MAP = {
|
|
0 commit comments