def main_list_journals(opts): for mtime, id, summary in Journal.journals(): dt = datetime.datetime.fromtimestamp(mtime) if log.isEnabledFor(logging.DEBUG): print "-- [%s, %s] %s" % (id, dt, summary) j = Journal.load(id) for record in j: print repr(record) for hit in record.rhits: print " %r" % hit else: print "%s %s (at %s)" % (id, summary, dt)
def main_undo(opts): """Undo the given replacement.""" dry_run_str = (opts.dry_run and " (dry-run)" or "") journal_id = opts.undo if journal_id == "last": for mtime, id, summary in Journal.journals(): log.debug("last replace id is `%s'", id) journal_id = id break else: raise FrepError("there is no last replacement journal to undo") for rec in findlib2.undo_replace(journal_id, dry_run=opts.dry_run): if not isinstance(rec, findlib2.JournalReplaceRecord): log.debug(rec) continue s_str = (len(rec.rhits) > 1 and "s" or "") log.info("%s: undo %s replacement%s%s", rec.nicepath, len(rec.rhits), s_str, dry_run_str)