Commands: updated for JSON formatted comments with history
This commit is contained in:
@ -12,7 +12,8 @@ from obitools3.utils cimport tobytes
|
||||
from functools import reduce
|
||||
import time
|
||||
import re
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
__title__="Grep view lines that match the given predicates"
|
||||
|
||||
@ -29,7 +30,7 @@ def addOptions(parser):
|
||||
group=parser.add_argument_group("obi grep specific options")
|
||||
|
||||
group.add_argument("--predicate", "-p",
|
||||
action="append", dest="grep:predicates",
|
||||
action="append", dest="grep:grep_predicates",
|
||||
metavar="<PREDICATE>",
|
||||
default=None,
|
||||
type=str,
|
||||
@ -306,12 +307,22 @@ def run(config):
|
||||
|
||||
# Create output view with the line selection
|
||||
try:
|
||||
o_view = selection.materialize(output_view_name, comments="obi grep: "+str(config["grep"])+"\n")
|
||||
o_view = selection.materialize(output_view_name)
|
||||
except Exception, e:
|
||||
raise RollbackException("obi grep error, rollbacking view: "+str(e), o_view)
|
||||
|
||||
# TODO DISCUSS if output URI to different DMS, copy view?
|
||||
|
||||
# Save command config in View and DMS comments
|
||||
command_line = " ".join(sys.argv[1:])
|
||||
input_dms_name=[input[0].name]
|
||||
input_view_name=[input[1].name]
|
||||
if 'taxoURI' in config['obi'] and config['obi']['taxoURI'] is not None:
|
||||
input_dms_name.append(config['obi']['taxoURI'].split("/", 1)[0])
|
||||
input_view_name.append(config['obi']['taxoURI'].split("/", 1)[1])
|
||||
o_view.write_config(config, "grep", command_line, input_dms_name=input_dms_name, input_view_name=input_view_name)
|
||||
input[0].record_command_line(command_line) # TODO assuming input and output dms are the same
|
||||
|
||||
print("\n")
|
||||
print(repr(o_view))
|
||||
|
||||
|
Reference in New Issue
Block a user