Fixed comments bug with obi head and obi tail

This commit is contained in:
Celine Mercier
2018-10-21 17:39:17 +02:00
parent e18b762d81
commit d53323e7f4
3 changed files with 14 additions and 5 deletions

2
python/obitools3/commands/head.pyx Normal file → Executable file
View File

@ -65,7 +65,7 @@ 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:

2
python/obitools3/commands/tail.pyx Normal file → Executable file
View File

@ -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:

11
python/obitools3/dms/view/view.pyx Normal file → Executable file
View File

@ -399,6 +399,15 @@ cdef class View(OBIWrapper) :
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
def write_config(self, dict config, str command_name, str command_line, list input_str=None, list input_dms_name=None, list input_view_name=None):
self.comments = View._config_to_dict(config, command_name, command_line, \
@ -611,7 +620,7 @@ cdef class View_comments(dict): # Not thread safe
comments_json = <bytes> 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):