Commit 1849b8ad authored by Daniel Eggert's avatar Daniel Eggert
Browse files

version 0.1.4; fixed imports once more

parent f001763d
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
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):
......
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
......@@ -13,7 +13,7 @@ except ImportError:
print(readme)
version='0.1.3'
version='0.1.4'
setup(
name='deprogressapi',
......
Markdown is supported
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