Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digitalearth
DASF Data Analytics Software Framework
dasf-progress-api
Commits
1849b8ad
Commit
1849b8ad
authored
Jul 01, 2021
by
Daniel Eggert
Browse files
version 0.1.4; fixed imports once more
parent
f001763d
Changes
4
Hide whitespace changes
Inline
Side-by-side
deprogressapi/__init__.py
View file @
1849b8ad
from
.progress_report
import
ProgressReport
from
.send_handler_interface
import
FormalProgressInterface
\ No newline at end of file
from
.progress_report
import
ProgressReport
,
FormalProgressInterface
\ No newline at end of file
deprogressapi/progress_report.py
View file @
1849b8ad
from
typing
import
List
from
.send_handler_interface
import
FormalProgressInterface
import
abc
import
json
def
report_to_json
(
report
:
'ProgressReport'
)
->
dict
:
return
{
'step_message'
:
report
.
step_message
,
'steps'
:
report
.
steps
,
'completed'
:
report
.
completed
,
'children'
:
[
report_to_json
(
child
)
for
child
in
report
.
children
]
}
class
FormalProgressInterface
(
metaclass
=
abc
.
ABCMeta
):
def
__init__
(
self
):
self
.
__root_progress
=
None
def
set_root_progress_report
(
self
,
progress_report_root
:
'ProgressReport'
):
self
.
__root_progress
=
progress_report_root
self
.
submit
()
def
has_root
(
self
)
->
bool
:
return
self
.
__root_progress
is
not
None
def
submit
(
self
):
if
self
.
__root_progress
:
self
.
send
(
json
.
dumps
(
report_to_json
(
self
.
__root_progress
)))
def
get_data
(
self
):
return
report_to_json
(
self
.
__root_progress
)
@
abc
.
abstractmethod
def
send
(
self
,
progress_json
:
str
):
pass
class
ProgressReport
:
def
__init__
(
self
,
step_message
:
str
,
send_handler
:
FormalProgressInterface
,
steps
:
int
=
0
):
...
...
deprogressapi/send_handler_interface.py
deleted
100644 → 0
View file @
f001763d
import
abc
import
json
from
.progress_report
import
ProgressReport
def
report_to_json
(
report
:
'ProgressReport'
)
->
dict
:
return
{
'step_message'
:
report
.
step_message
,
'steps'
:
report
.
steps
,
'completed'
:
report
.
completed
,
'children'
:
[
report_to_json
(
child
)
for
child
in
report
.
children
]
}
class
FormalProgressInterface
(
metaclass
=
abc
.
ABCMeta
):
def
__init__
(
self
):
self
.
__root_progress
=
None
def
set_root_progress_report
(
self
,
progress_report_root
:
ProgressReport
):
self
.
__root_progress
=
progress_report_root
self
.
submit
()
def
has_root
(
self
)
->
bool
:
return
self
.
__root_progress
is
not
None
def
submit
(
self
):
if
self
.
__root_progress
:
self
.
send
(
json
.
dumps
(
report_to_json
(
self
.
__root_progress
)))
def
get_data
(
self
):
return
report_to_json
(
self
.
__root_progress
)
@
abc
.
abstractmethod
def
send
(
self
,
progress_json
:
str
):
pass
setup.py
View file @
1849b8ad
...
...
@@ -13,7 +13,7 @@ except ImportError:
print
(
readme
)
version
=
'0.1.
3
'
version
=
'0.1.
4
'
setup
(
name
=
'deprogressapi'
,
...
...
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