From dec114eed6a26d9eebd96a76e085c3e59383a9c5 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Mon, 27 Jul 2020 17:38:45 +0200 Subject: [PATCH] Python: added "date created" information in view representation --- python/obitools3/commands/test.pyx | 6 ++++-- python/obitools3/dms/view/view.pyx | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/python/obitools3/commands/test.pyx b/python/obitools3/commands/test.pyx index 64c3e05..0e1ac8c 100755 --- a/python/obitools3/commands/test.pyx +++ b/python/obitools3/commands/test.pyx @@ -23,6 +23,7 @@ from obitools3.dms.capi.obiview cimport NUC_SEQUENCE_COLUMN, \ import shutil import string import random +import sys from cpython.exc cimport PyErr_CheckSignals @@ -366,7 +367,7 @@ def random_new_view(config, infos, first=False): infos['view'] = View_NUC_SEQS.new(infos['dms'], random_unique_name(infos), comments=random_comments(config)) # TODO quality column else : infos['view'] = View.new(infos['dms'], random_unique_name(infos), comments=random_comments(config)) # TODO quality column - + infos['view'].write_config(config, "test", infos["command_line"], input_dms_name=[infos['dms'].name], input_view_name=["random"]) print_test(config, repr(infos['view'])) if v_to_clone is not None : if line_selection is None: @@ -497,7 +498,8 @@ def run(config): (b"OBI_SEQ", False): random_seq, (b"OBI_SEQ", True): random_seq_tuples, (b"OBI_STR", False): random_bytes, (b"OBI_STR", True): random_bytes_tuples }, - 'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias, test_new_view] + 'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias, test_new_view], + 'command_line': " ".join(sys.argv[1:]) } # TODO ??? diff --git a/python/obitools3/dms/view/view.pyx b/python/obitools3/dms/view/view.pyx index 33d4a67..ceb0010 100755 --- a/python/obitools3/dms/view/view.pyx +++ b/python/obitools3/dms/view/view.pyx @@ -184,9 +184,15 @@ cdef class View(OBIWrapper) : @OBIWrapper.checkIsActive - def __repr__(self) : - cdef str s = "#View name:\n{name:s}\n#Line count:\n{line_count:d}\n#Columns:\n".format(name = bytes2str(self.name), - line_count = self.line_count) + def __repr__(self) : + cdef str s + if self.read_only: # can read date + s = "#View name:\n{name:s}\n#Date created:\n{date:s}\n#Line count:\n{line_count:d}\n#Columns:\n".format(name = bytes2str(self.name), + line_count = self.line_count, + date = str(bytes2str_object(self.comments["Date created"]))) + else: + s = "#View name:\n{name:s}\n#Line count:\n{line_count:d}\n#Columns:\n".format(name = bytes2str(self.name), + line_count = self.line_count) for column_name in self.keys() : s = s + repr(self[column_name]) + '\n' return s