def pformat_atom_detail(atom_detail, indent=0): """Pretty formats a atom detail.""" detail_type = logbook.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 "\n".join(lines)
def _atomdetails_merge(ad_m, ad): atom_type = logbook.atom_detail_type(ad) if atom_type != ad_m.atom_type: raise exc.StorageFailure("Can not merge differing atom types " "(%s != %s)" % (atom_type, ad_m.atom_type)) ad_d = ad.to_dict() ad_m.state = ad_d['state'] ad_m.intention = ad_d['intention'] ad_m.results = ad_d['results'] ad_m.version = ad_d['version'] ad_m.failure = ad_d['failure'] ad_m.meta = ad_d['meta'] ad_m.name = ad_d['name'] return ad_m
def _convert_ad_to_internal(ad, parent_uuid): converted = ad.to_dict() converted['atom_type'] = logbook.atom_detail_type(ad) converted['parent_uuid'] = parent_uuid return models.AtomDetail(**converted)
def _format_atom(atom_detail): return { 'atom': atom_detail.to_dict(), 'type': logbook.atom_detail_type(atom_detail), }
def _insert_atom_details(self, conn, ad, parent_uuid): value = ad.to_dict() value['parent_uuid'] = parent_uuid value['atom_type'] = logbook.atom_detail_type(ad) conn.execute(sql.insert(self._tables.atomdetails, value))