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

Languages

Previous versions

1.2
1.1

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.

Parameters:
  • 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:

_path

equals to path

_filename

equals to filename

_is_valid

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.

_set_valid()[source]

Sets the file as valid

_set_invalid()[source]

Sets the file as invalid

is_valid()[source]

Returns True if the file has been successfully parsed.

attributes[source]

List of the attributes which have been successfully set.