ucsschool.import_lusd package#

Submodules#

ucsschool.import_lusd.cli module#

A UCS@school command line interface to fetch user and group data from LUSD and import the fetched data into the UCS@school domain.

exception ucsschool.import_lusd.cli.ConfigurationError[source]#

Bases: ValueError

class ucsschool.import_lusd.cli.Configuration(lusd_api_url: str, lusd_api_oauth_iss: str, school_authority: str, skip_fetch: bool, skip_students: bool, skip_teachers: bool, dry_run: bool, student_import_config_path: pathlib.Path, teacher_import_config_path: pathlib.Path, log_level: str = 'ERROR', school_id_map: Dict[str, List[str]] = <factory>, authentication_key_file_path: pathlib.Path = PosixPath('/var/lib/ucs-school-import-lusd/auth_key'), lusd_data_save_path: pathlib.Path = PosixPath('/var/lib/ucs-school-import-lusd/data'), ucs_school_import_cli: pathlib.Path = PosixPath('/usr/share/ucs-school-import/scripts/ucs-school-user-import'))[source]#

Bases: object

lusd_api_url: str#
lusd_api_oauth_iss: str#
school_authority: str#
skip_fetch: bool#
skip_students: bool#
skip_teachers: bool#
dry_run: bool#
student_import_config_path: Path#
teacher_import_config_path: Path#
log_level: str = 'ERROR'#
school_id_map: Dict[str, List[str]]#
authentication_key_file_path: Path = PosixPath('/var/lib/ucs-school-import-lusd/auth_key')#
lusd_data_save_path: Path = PosixPath('/var/lib/ucs-school-import-lusd/data')#
ucs_school_import_cli: Path = PosixPath('/usr/share/ucs-school-import/scripts/ucs-school-user-import')#
validate() None[source]#

Validate the values stored in the configuration.

ucsschool.import_lusd.cli.normalize_schools(school_id_map: Dict[str, str]) Dict[str, List[str]][source]#
class ucsschool.import_lusd.cli.ImportLUSD(args: Namespace)[source]#

Bases: object

run_import() None[source]#
fetch_and_store_lusd_data() None[source]#

fetch and store data for all configured schools

skip_role(role: str) bool[source]#
get_bearer_token() str[source]#
fetch_school_lusd_data(school_ids: List[str], role: str, file_path: Path) Any[source]#

Store LUSD data for school school_ids in file_path

get_lusd_data_save_path(school_name: str, role: str) Path[source]#
run_sisopi_import(school_name: str) None[source]#

Run a single SiSoPi import for school school_name

validate_dienststellennummern() None[source]#
setup_logging() None[source]#
ucsschool.import_lusd.cli.get_args() Namespace[source]#
ucsschool.import_lusd.cli.run() None[source]#

ucsschool.import_lusd.reader module#

class ucsschool.import_lusd.reader.LUSDReader(filename: str, header_lines: int = 0, **kwargs: Any)[source]#

Bases: CsvReader

Parameters:
  • filename (str) – Path to file with user data.

  • header_lines (int) – Number of lines before the actual data starts.

  • kwargs (dict) – optional parameters for use in derived classes

read() Generator[Dict[str, str], None, None][source]#

Generate dicts from a JSON file. :return: iterator over list of dicts :rtype: Generator[Dict[str, str], None, None]

lusd_preprocessing(user_obj: Dict[str, Any]) None[source]#

Convert LUSD API attributes which are arrays to string to be conform with the CsvReader

handle_input(mapping_key: str, mapping_value: str, value: str, import_user: ImportUser) bool[source]#

This is a hook into map().

LUSD specific input handling

Parameters:
  • mapping_key (str) – the key in config[“csv”][“mapping”]

  • mapping_value (str) – the value in config[“csv”][“mapping”]

  • value (str) – the associated value from the JSON object

  • import_user (ImportUser) – the object to modify

Returns:

True if the field was handled here. It will be ignored in map(). False if map() should handle the field.

Return type:

bool