-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmanagement.py
More file actions
35 lines (28 loc) · 1 KB
/
management.py
File metadata and controls
35 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os, sys, json
# File name and property file munging. Coordinates with Makefile.
def issue_root(spec):
root = os.path.join('r', spec)
if os.path.isdir(root):
return root
head = os.path.join('r', spec + '-HEAD')
if os.path.isdir(head):
return head
print '** found neither %s nor %s' % (root, head)
def resource_path(spec):
return os.path.join(issue_root(spec), 'resource', '')
def source_path(spec):
return os.path.join(issue_root(spec), 'source', '')
def properties_path(spec):
return os.path.join(issue_root(spec), 'properties.json')
def get_property(spec, selector):
with open(properties_path(spec), 'r') as infile:
blob = json.load(infile)
return blob[selector]
def set_property(spec, selector, value):
props_path = properties_path(spec)
with open(props_path, 'r') as infile:
blob = json.load(infile)
blob[selector] = value
with open(props_path, 'w') as outfile:
json.dump(blob, outfile)
outfile.write('\n')