Filehandler

Base module with the base class for reading and writing different files.

Warning

This module will be deprecated in next releases. Follow updates on https://github.com/mathLab for news about file handling.

class FileHandler[source]

Bases: object

A base class for file handling.

Variables
  • infile (string) – name of the input file to be processed.

  • outfile (string) – name of the output file where to write in.

  • extensions (list) – extensions of the input/output files. It is specific for each subclass.

parse(*args)[source]

Abstract method to parse a specific file.

Not implemented, it has to be implemented in subclasses.

write(*args)[source]

Abstract method to write a specific file.

Not implemented, it has to be implemented in subclasses.

_check_extension(filename)[source]

This private class method checks if the given filename has the proper extension set in the child class. If not it raises a ValueError.

Parameters

filename (string) – file to check.

static _check_filename_type(filename)[source]

This private static method checks if filename is a string. If not it raises a TypeError.

Parameters

filename (string) – file to check.

_check_infile_instantiation()[source]

This private method checks if self.infile is instantiated. If not it means that nobody called the parse method and self.infile is None. If the check fails it raises a RuntimeError.