Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
exercisemodel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stw
wt
exercisemodel
Commits
1685b529
Commit
1685b529
authored
Nov 27, 2017
by
Tomas Pettersson
🏸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added taskinfo.properties handle
parent
90f5fb41
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
exercisemodel/__init__.py
exercisemodel/__init__.py
+27
-1
exercisemodel/__init__.pyc
exercisemodel/__init__.pyc
+0
-0
exercisemodel/model.pyc
exercisemodel/model.pyc
+0
-0
output.json
output.json
+1
-1
No files found.
exercisemodel/__init__.py
View file @
1685b529
...
...
@@ -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
=
{}
try
:
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
():
f
.
write
(
key
+
"="
+
value
+
"
\n
"
)
def
run
():
try
:
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
(
'taskinfo.properties'
)
if
props
.
has_key
(
"status"
):
props
[
'status'
]
=
"COMPLETE"
write_properties
(
'taskinfo.properties'
,
props
)
sys
.
exit
(
0
)
except
Exception
as
error
:
print_exc
()
sys
.
exit
(
1
)
'''
To run in terminal call with python
exercise
.py
To run in terminal call with python
__init__
.py
'''
if
__name__
==
"__main__"
:
storetree
()
exercisemodel/__init__.pyc
deleted
100644 → 0
View file @
90f5fb41
File deleted
exercisemodel/model.pyc
deleted
100644 → 0
View file @
90f5fb41
File deleted
output.json
View file @
1685b529
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment