Previous topic

5.6. filehandlers — Utilities to retrieve informations from a file

Next topic

5.6.2. filehandlers.odf — Handler for odf files

This Page


Previous versions


5.6.1. filehandlers.base — Base classes for filehandlers

class plmapp.filehandlers.base.HandlersManager[source]

Bases: object

The HandlersManager has methods to register a FileHandler with a type of file (an extension with the dot, like ".pdf") and to get a FileHandler from a typename.

In all methods, typename should be in lowercase and start with a dot.

classmethod register(typename, handler)[source]

Registers the subclass of FileHandler handler for typename.

classmethod get_best_handler(typename)[source]

Gets the best FileHandler associated to typename. The best handler is the first registered handler for typename.

classmethod get_all_handlers(typename)[source]

Returns a list of all FileHander associated to typename.

classmethod get_all_supported_types()[source]

Returns all supported types (a list of string).

class plmapp.filehandlers.base.FileHandler(path, filename)[source]

Bases: object

A FileHandler is an object which retrieves informations from a file and exposes this informations through its attributes.

  • path – path of the file that should be parsed
  • filename – original filename of the file (with its extension).

Tips for developpers

A FileHandler has the following protected attributes:


equals to path


equals to filename


True if the file has been successfully parsed. Set by default to False. You can use the methods _set_valid() and _set_invalid() to modify this attribute.


Sets the file as valid


Sets the file as invalid


Returns True if the file has been successfully parsed.


List of the attributes which have been successfully set.