File handler to support different file extensions. Uses reflectometry’s registry utility.
The default readers are found in the ‘readers’ sub-module and registered by default at initialization time.
To add a new default reader, one must register it in the register_readers method found in readers/__init__.py.
A utility method (find_plugins) is available to inspect a directory (for instance, a user plug-in directory) and look for new readers/writers.
Bases: object
Utility class to use the Registry as a singleton.
Append a reader object to readers
Parameters: |
|
---|
Look into a module to find whether it contains a Reader class. If so, append it to readers and (potentially) to the list of writers for the given extension
Parameters: |
|
---|
Find plugins in a given directory
Parameters: | dir – directory to look into to find new readers/writers |
---|
Load a file
Parameters: |
|
---|---|
Returns: | DataInfo object |
Save a DataInfo object to file :param file: file name (path) :param data: DataInfo object :param format: format to write the data in
Bases: data_util.registry.ExtensionRegistry
Registry class for file format extensions. Readers and writers are supported.
Append a reader object to readers
Parameters: |
|
---|
Look into a module to find whether it contains a Reader class. If so, APPEND it to readers and (potentially) to the list of writers for the given extension
Parameters: |
|
---|
Return a sorted list of registered extensions.
Find readers in a given directory. This method can be used to inspect user plug-in directories to find new readers/writers.
Parameters: | dir – directory to search into |
---|---|
Returns: | number of readers found |
Return a sorted list of the registered formats.
Call the loader for the file type of path.
Parameters: |
|
---|
Defaults to the ascii (multi-column) reader if no reader was registered for the file’s extension.
Return the loader associated with the file type of path.
Raises ValueError if file type is not known.
Returns: | the loader associated with the file type of path. |
---|---|
Raises ValueError: | |
if file type is not known. |
Call the writer for the file type of path.
Raises ValueError if no writer is available. Raises KeyError if format is not available.
May raise a writer-defined exception if writer fails.