Skip to content

Secretary¤

secretary ¤

High level manager of all server connectors and bank of filters:

  • load available connector modules,
  • pass them the content of the relevant settings.ini section,
  • open and close the remote connections to servers by calling internal connector methods,
  • process all filters of a given config subfolder in sequence by calling the internal run_filters method of each connector.

© 2022-2023 Aurélien Pierre

Classes¤

Secretary ¤

Secretary(subfolder_path: str, server_mode: bool, number: int, force: bool)

Bases: object

Backbone class managing the collection of available connectors. It is called from src/main.py.

Load configuration from settings.ini file in the current folder. Load all connector modules from protocols.

PARAMETER DESCRIPTION
subfolder_path

the current folder of filters

TYPE: str

server_mode

enable or disable the server mode, which makes processing slower to better share limited resources on a server.

TYPE: bool

number

override the number of items to process defined in config file. -1 honors config files settings.

TYPE: int

force

ignore logs and reprocess items already processed.

TYPE: bool

ATTRIBUTE DESCRIPTION
protocols

connectors.Server): available [connectors.Server][] implementations for server protocols. They are exposed to user filters in globals().

TYPE: dict of str

config_file

object handling the settings.ini content for the current config folder.

TYPE: configparser.ConfigParser

log_file

object handling the main sync.log for the whole application, where every action on [connectors.Content][] will be logged.

TYPE: io.TextIOWrapper

Functions¤
load_connectors ¤
load_connectors()

Iterate over all connectors for which we have both an implementation and credentials in the congig file. Initialize them and append them to the dictionnary [protocols][]

close_connectors ¤
close_connectors()

Iterate over all initialized connectors and close the connections. Then close the logfile.

filters ¤
filters(filters: utils.filter_bank)

Process the loop over Content objects from the implementation of [connectors.Server.run_filters][] for each filter.

PARAMETER DESCRIPTION
filters

iterable of available filters. See [utils.filter_bank][].

TYPE: utils.filter_bank

server_breathe ¤
server_breathe()

If server mode is enabled, introduce a 0.5 s timeout to let other processes run. This is useful where heavy text parsing happens