https://github.com/astrofrog/astropy_io_refactor
https://github.com/astrofrog/astropy_io_refactor
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/astrofrog/astropy_io_refactor
- Owner: astrofrog
- Created: 2014-04-06T20:50:08.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-06T20:51:56.000Z (over 12 years ago)
- Last Synced: 2025-02-23T01:46:17.353Z (over 1 year ago)
- Language: Python
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
About
-----
This is a demonstration of a proposed new I/O unified framework. The goal of
this framework is to:
* define readers/writers/identifiers as file format-specific and data-class
specific IO classes (e.g. VOTableIO)
* define all the documentation related to each reader/writer locally to the
actual code.
* defer importing the classes defining I/O until the last minute.
Downsides of the current approach:
* We have to refer to the supported class (e.g. ``Table`` or ``NDData``) by
name instead of by the class itself - this is needed for two reasons:
* To prevent circular imports, ``_supported_class`` has to be a string,
not the data class.
* the ``fix_docstring`` decorator can't take the class itself, it has to
take the name of the class.
Notes:
* The code is very hacky - things like text wrap and so on can be dealt with
much better, but this is just meant to be a 'toy model' of the
infrastructure.
Files
-----
* ``connect_txt.py`` - defines a .txt reader
* ``registry.py`` - main registry module
* ``table.py`` - Table class definition
* ``test.py`` and ``data.txt`` - test files
Example
-------
In [1]: from table import Table
In [2]: print(Table.read.__doc__)
Read and parse a data table and return as a Table.
Parameters
----------
format : str
Explicilty specify the format. See the `Notes`_ below for the
available formats and options.
Notes
-----
In addition to the ``format`` argumnet, the remaining arguments
depend on the format used. The following formats are availale, along
with the relevant arguments in each case:
* ``format='txt'``
filename : str
The name of the file to read from
skiprows : int
How many rows to skip at the start of the file
In [3]: t = Table.read('data.txt')
In [4]: print(t)
[ 1. 2. 3.]
In the above example, the docstring was generated automatically