Commit 1685b529 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

added handle

parent 90f5fb41
......@@ -28,6 +28,27 @@ def storetree():
with open('resources/strtree.pickle', 'wb') as handle:
pickle.dump(sections, handle, protocol=pickle.HIGHEST_PROTOCOL)
def read_properties(filepath, sep='=', comment_char='#'):
props = {}
with open(filepath, "rt") as f:
for line in f:
l = line.strip()
if l and not l.startswith(comment_char):
key_value = l.split(sep)
key = key_value[0].strip()
value = sep.join(key_value[1:]).strip().strip('"')
props[key] = value
except IOError:
return props
return props
def write_properties(filepath, props):
with open(filepath, "wt") as f:
for key, value in props.iteritems():
def run():
strtree = STRtree(pickle.load(pkg_resources.resource_stream(__name__, '/'.join(('resources', 'strtree.pickle')))))
......@@ -55,12 +76,17 @@ def run():
with open('output.json',"w") as outputfile:
json.dump(output, outputfile)
props = read_properties('')
if props.has_key("status"):
props['status'] = "COMPLETE"
write_properties('', props)
except Exception as error:
To run in terminal call with python
To run in terminal call with python
if __name__ == "__main__":
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment