summaryrefslogtreecommitdiff
path: root/taskflow/utils
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-07-21 21:36:34 +0000
committerGerrit Code Review <review@openstack.org>2015-07-21 21:36:34 +0000
commit357103d27c87263cbe783523a77006d76b52ad0e (patch)
treed45db22585b7ddc9ad905cf1d951055080f2ec0b /taskflow/utils
parent592b46841681215a9b131017bd976f9dc7cb1f28 (diff)
parent02c83d40612bbe3146a9f2ff212759ecdcdeb8ba (diff)
downloadtaskflow-357103d27c87263cbe783523a77006d76b52ad0e.tar.gz
Merge "Remove **most** usage of taskflow.utils in examples"
Diffstat (limited to 'taskflow/utils')
-rw-r--r--taskflow/utils/persistence_utils.py75
1 files changed, 0 insertions, 75 deletions
diff --git a/taskflow/utils/persistence_utils.py b/taskflow/utils/persistence_utils.py
index 0837afb..1d4dc26 100644
--- a/taskflow/utils/persistence_utils.py
+++ b/taskflow/utils/persistence_utils.py
@@ -15,14 +15,11 @@
# under the License.
import contextlib
-import os
-from oslo_utils import timeutils
from oslo_utils import uuidutils
from taskflow import logging
from taskflow.persistence import models
-from taskflow.utils import misc
LOG = logging.getLogger(__name__)
@@ -97,75 +94,3 @@ def create_flow_detail(flow, book=None, backend=None, meta=None):
return book.find(flow_id)
else:
return flow_detail
-
-
-def _format_meta(metadata, indent):
- """Format the common metadata dictionary in the same manner."""
- if not metadata:
- return []
- lines = [
- '%s- metadata:' % (" " * indent),
- ]
- for (k, v) in metadata.items():
- # Progress for now is a special snowflake and will be formatted
- # in percent format.
- if k == 'progress' and isinstance(v, misc.NUMERIC_TYPES):
- v = "%0.2f%%" % (v * 100.0)
- lines.append("%s+ %s = %s" % (" " * (indent + 2), k, v))
- return lines
-
-
-def _format_shared(obj, indent):
- """Format the common shared attributes in the same manner."""
- if obj is None:
- return []
- lines = []
- for attr_name in ("uuid", "state"):
- if not hasattr(obj, attr_name):
- continue
- lines.append("%s- %s = %s" % (" " * indent, attr_name,
- getattr(obj, attr_name)))
- return lines
-
-
-def pformat_atom_detail(atom_detail, indent=0):
- """Pretty formats a atom detail."""
- detail_type = models.atom_detail_type(atom_detail)
- lines = ["%s%s: '%s'" % (" " * (indent), detail_type, atom_detail.name)]
- lines.extend(_format_shared(atom_detail, indent=indent + 1))
- lines.append("%s- version = %s"
- % (" " * (indent + 1), misc.get_version_string(atom_detail)))
- lines.append("%s- results = %s"
- % (" " * (indent + 1), atom_detail.results))
- lines.append("%s- failure = %s" % (" " * (indent + 1),
- bool(atom_detail.failure)))
- lines.extend(_format_meta(atom_detail.meta, indent=indent + 1))
- return os.linesep.join(lines)
-
-
-def pformat_flow_detail(flow_detail, indent=0):
- """Pretty formats a flow detail."""
- lines = ["%sFlow: '%s'" % (" " * indent, flow_detail.name)]
- lines.extend(_format_shared(flow_detail, indent=indent + 1))
- lines.extend(_format_meta(flow_detail.meta, indent=indent + 1))
- for task_detail in flow_detail:
- lines.append(pformat_atom_detail(task_detail, indent=indent + 1))
- return os.linesep.join(lines)
-
-
-def pformat(book, indent=0):
- """Pretty formats a logbook."""
- lines = ["%sLogbook: '%s'" % (" " * indent, book.name)]
- lines.extend(_format_shared(book, indent=indent + 1))
- lines.extend(_format_meta(book.meta, indent=indent + 1))
- if book.created_at is not None:
- lines.append("%s- created_at = %s"
- % (" " * (indent + 1),
- timeutils.isotime(book.created_at)))
- if book.updated_at is not None:
- lines.append("%s- updated_at = %s"
- % (" " * (indent + 1),
- timeutils.isotime(book.updated_at)))
- for flow_detail in book:
- lines.append(pformat_flow_detail(flow_detail, indent=indent + 1))
- return os.linesep.join(lines)