From bbb06001f99d1484615760e69771217a342a3bdd Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Sat, 7 May 2011 00:04:07 +0200 Subject: [PATCH] improve documentation for table class --- modules/base/pymod/table.py | 22 +++++++++++++++++++--- modules/index.rst | 6 +++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py index dc609a7e4..c770fdc9e 100644 --- a/modules/base/pymod/table.py +++ b/modules/base/pymod/table.py @@ -448,10 +448,26 @@ class Table: return filt_tab @staticmethod - def Load(stream): + def Load(stream_or_filename): + """ + Load table from stream or file with given name. The file must contain a + header line of the form + + col_name1[type1] <col_name2[type2]>... + + The types given in brackets must be one of the data types the :class:`Table` + class understands. Each following line in the file then must contains exactly + the same number of data items as listed in the header. The data items are + automatically converted to the column format. Lines starting with a '#' and + empty lines are ignored. + + :returns: A new :class:`Table` instance + """ fieldname_pattern=re.compile(r'(?P<name>[A-Za-z0-9_]+)(\[(?P<type>\w+)\])?') - if not hasattr(stream, 'read'): - stream=open(stream, 'r') + if not hasattr(stream_or_filename, 'read'): + stream=open(stream_or_filename, 'r') + else: + stream=stream_or_filename header=False num_lines=0 for line in stream: diff --git a/modules/index.rst b/modules/index.rst index 05c38c4dc..8cc338a82 100644 --- a/modules/index.rst +++ b/modules/index.rst @@ -26,7 +26,8 @@ OpenStructure documentation newmodule external contributing - + table + For Starters -------------------------------------------------------------------------------- @@ -85,7 +86,10 @@ Graphical User Interface **Widgets**: :doc:`python shell <gui/python_shell>` | :doc:`sequence viewer <gui/sequence_viewer>` +Varia +-------------------------------------------------------------------------------- +**Datasets:** :doc:`tabular data <table>` Extending OpenStructure -------------------------------------------------------------------------------- -- GitLab