diff --git a/python/obitools3/commands/head.pyx b/python/obitools3/commands/head.pyx old mode 100644 new mode 100755 index 088e8e6..f40ab1f --- a/python/obitools3/commands/head.pyx +++ b/python/obitools3/commands/head.pyx @@ -65,14 +65,14 @@ def run(config): # Save command config in View comments command_line = " ".join(sys.argv[1:]) - comments = View.print_config(config, "head", command_line, input_dms_name=[i_dms.name], input_view_name=[i_view.name]) - + comments = View.get_config_dict(config, "head", command_line, input_dms_name=[i_dms.name], input_view_name=[i_view.name]) + # Create output view with the line selection try: o_view = selection.materialize(output_view_name, comments=comments) except Exception, e: raise RollbackException("obi head error, rollbacking view: "+str(e), o_view) - + # TODO DISCUSS if output URI to different DMS, copy view? # Save command config in DMS comments diff --git a/python/obitools3/commands/tail.pyx b/python/obitools3/commands/tail.pyx old mode 100644 new mode 100755 index 25af7af..ae32468 --- a/python/obitools3/commands/tail.pyx +++ b/python/obitools3/commands/tail.pyx @@ -65,7 +65,7 @@ def run(config): # Save command config in View comments command_line = " ".join(sys.argv[1:]) - comments = View.print_config(config, "tail", command_line, input_dms_name=[i_dms.name], input_view_name=[i_view.name]) + comments = View.get_config_dict(config, "tail", command_line, input_dms_name=[i_dms.name], input_view_name=[i_view.name]) # Create output view with the line selection try: diff --git a/python/obitools3/dms/view/view.pyx b/python/obitools3/dms/view/view.pyx old mode 100644 new mode 100755 index 2b19bdc..c5c6ac5 --- a/python/obitools3/dms/view/view.pyx +++ b/python/obitools3/dms/view/view.pyx @@ -397,6 +397,15 @@ cdef class View(OBIWrapper) : # Convert to json string comments_json = json.dumps(config_dict) return str2bytes(comments_json) + + + @staticmethod + def get_config_dict(dict config, str command_name, str command_line, list input_str=None, list input_dms_name=None, list input_view_name=None): + config_dict = View._config_to_dict(config, command_name, command_line, \ + input_str=input_str, input_dms_name=input_dms_name, input_view_name=input_view_name) + # Clean virtually empty values + config_dict = clean_empty_values_from_object(config_dict, exclude=[View_comments.KEEP_KEYS]) + return config_dict @OBIWrapper.checkIsActive @@ -611,7 +620,7 @@ cdef class View_comments(dict): # Not thread safe comments_json = view_p.infos.comments comments_json_str = bytes2str(comments_json) comments_dict = json.loads(comments_json_str) - str2bytes_object(comments_dict) + comments_dict = str2bytes_object(comments_dict) super(View_comments, self).update(comments_dict) def __getitem__(self, object key):