ucsschool.importer.legacy package

Submodules

ucsschool.importer.legacy.legacy_csv_reader module

CSV reader for CSV files using the legacy import format.

class ucsschool.importer.legacy.legacy_csv_reader.LegacyCsvReader(filename, header_lines=0, **kwargs)[source]

Bases: ucsschool.importer.reader.csv_reader.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
handle_input(mapping_key, mapping_value, csv_value, import_user)[source]

Mark __is_staff and __is_teacher as already handled (in get_roles()). Handle __activate (reverse meaning of user.disabled).

get_roles(input_data)[source]

Detect the ucsschool.lib.roles from the input data.

Parameters:input_data (dict) – dict user from read()
Returns:[ucsschool.lib.roles, ..]
Return type:list(str)
_get_missing_columns()[source]

Find fieldnames that were configured in the csv:mapping but are missing in the input data.

In the legacy import password is not officially supported, but the original import script did support it if present, so we must it here too.

Returns:list(str)

ucsschool.importer.legacy.legacy_csv_user_import_factory module

Factory implementation for import using CSV in legacy format.

class ucsschool.importer.legacy.legacy_csv_user_import_factory.LegacyCsvUserImportFactory[source]

Bases: ucsschool.importer.default_user_import_factory.DefaultUserImportFactory

make_reader(**kwargs)[source]

Creates a reader for legacy CSV files.

Parameters:kwarg – passed to the reader constructor
Returns:a BaseReader object
Return type:LegacyCsvReader
make_import_user(cur_user_roles, *arg, **kwargs)[source]

Creates a LegacyImportUser of specific type.

:param func:list cur_user_roles: [ucsschool.lib.roles, ..] :param func:list arg: passed to constructor of created class :param dict kwarg: passed to constructor of created class :return: object of LegacyImportUser subclass :rtype: LegacyImportUser

make_password_exporter(*arg, **kwargs)[source]

Creates a ResultExporter object that can dump passwords to disk.

:param func:list arg: passed to constructor of created class :param dict kwarg: passed to constructor of created class :return: ResultExporter object :rtype: LegacyNewUserPasswordCsvExporter

make_user_importer(dry_run=True)[source]

Creates a user importer.

Parameters:dry_run (bool) – set to False to actually commit changes to LDAP
Returns:UserImport object
Return type:LegacyUserImport

ucsschool.importer.legacy.legacy_import_user module

ImportUser subclass for import using legacy CSV format.

class ucsschool.importer.legacy.legacy_import_user.LegacyImportUser(name=None, school=None, **kwargs)[source]

Bases: ucsschool.importer.models.import_user.ImportUser

Create ImportUser object (neither saved nor loaded from LDAP yet). The dn attribute is calculated.

Parameters:
  • name (str) – username
  • school (str) – OU
  • kwargs – attributes to set on user object
make_disabled()[source]

Handled in LegacyCsvReader.handle_input(). Overwriting here, so changes in ImportUser do not change behavior of LegacyImportUser.

make_firstname()[source]

Do not normalize given names.

make_lastname()[source]

Do not normalize family names.

make_username()[source]
validate(lo, validate_unlikely_changes=False, check_username=False)[source]

Action must already be configured in CSV.

_check_username_uniqueness()[source]

Check that self.name is not already in use by another user.

Raises:UniqueIdError – if username is already taken by another user
classmethod get_by_import_id_or_username(connection, source_uid, record_uid, username, superordinate=None)[source]

Retrieve a LegacyImportUser. Will find it using either source_uid and record_uid or if unset with the username.

Parameters:
  • connection (univention.admin.uldap.access) – uldap object
  • source_uid (str) – source DB identifier
  • record_uid (str) – source record identifier
  • username (str) – username
  • superordinate (str) – superordinate
Returns:

object of ImportUser subclass loaded from LDAP or raises noObject

Return type:

ImportUser

Raises:

noObject – if no user object was found

classmethod get_class_for_udm_obj(udm_obj, school)[source]

IMPLEMENTME if you subclass!

Parameters:
_attributes = {'school': <ucsschool.lib.models.attributes.SchoolAttribute object>, 'name': <ucsschool.lib.models.attributes.Username object>, 'firstname': <ucsschool.lib.models.attributes.Firstname object>, 'lastname': <ucsschool.lib.models.attributes.Lastname object>, 'ucsschool_roles': <ucsschool.lib.models.attributes.Roles object>, 'school_classes': <ucsschool.lib.models.attributes.SchoolClassesAttribute object>, 'disabled': <ucsschool.lib.models.attributes.Disabled object>, 'birthday': <ucsschool.lib.models.attributes.Birthday object>, 'record_uid': <ucsschool.lib.models.attributes.RecordUID object>, 'schools': <ucsschool.lib.models.attributes.Schools object>, 'password': <ucsschool.lib.models.attributes.Password object>, 'source_uid': <ucsschool.lib.models.attributes.SourceUID object>, 'email': <ucsschool.lib.models.attributes.Email object>}
_meta = <ucsschool.lib.models.meta.UCSSchoolHelperOptions object>
logger = <Proxy at 0x7fc5456275f0 wrapping <celery.utils.log.ProcessAwareLogger object> at 0x7fc5452e48d0 with factory <function <lambda>>>
class ucsschool.importer.legacy.legacy_import_user.LegacyImportStudent(name=None, school=None, **kwargs)[source]

Bases: ucsschool.importer.legacy.legacy_import_user.LegacyImportUser, ucsschool.importer.models.import_user.ImportStudent

Create ImportUser object (neither saved nor loaded from LDAP yet). The dn attribute is calculated.

Parameters:
  • name (str) – username
  • school (str) – OU
  • kwargs – attributes to set on user object
_attributes = {'firstname': <ucsschool.lib.models.attributes.Firstname object>, 'lastname': <ucsschool.lib.models.attributes.Lastname object>, 'disabled': <ucsschool.lib.models.attributes.Disabled object>, 'birthday': <ucsschool.lib.models.attributes.Birthday object>, 'record_uid': <ucsschool.lib.models.attributes.RecordUID object>, 'schools': <ucsschool.lib.models.attributes.Schools object>, 'password': <ucsschool.lib.models.attributes.Password object>, 'source_uid': <ucsschool.lib.models.attributes.SourceUID object>, 'school': <ucsschool.lib.models.attributes.SchoolAttribute object>, 'name': <ucsschool.lib.models.attributes.Username object>, 'ucsschool_roles': <ucsschool.lib.models.attributes.Roles object>, 'school_classes': <ucsschool.lib.models.attributes.SchoolClassesAttribute object>, 'email': <ucsschool.lib.models.attributes.Email object>}
_meta = <ucsschool.lib.models.meta.UCSSchoolHelperOptions object>
logger = <Proxy at 0x7fc5456273b0 wrapping <celery.utils.log.ProcessAwareLogger object> at 0x7fc5452e48d0 with factory <function <lambda>>>
class ucsschool.importer.legacy.legacy_import_user.LegacyImportStaff(name=None, school=None, **kwargs)[source]

Bases: ucsschool.importer.legacy.legacy_import_user.LegacyImportUser, ucsschool.importer.models.import_user.ImportStaff

Create ImportUser object (neither saved nor loaded from LDAP yet). The dn attribute is calculated.

Parameters:
  • name (str) – username
  • school (str) – OU
  • kwargs – attributes to set on user object
_attributes = {'firstname': <ucsschool.lib.models.attributes.Firstname object>, 'lastname': <ucsschool.lib.models.attributes.Lastname object>, 'disabled': <ucsschool.lib.models.attributes.Disabled object>, 'birthday': <ucsschool.lib.models.attributes.Birthday object>, 'record_uid': <ucsschool.lib.models.attributes.RecordUID object>, 'schools': <ucsschool.lib.models.attributes.Schools object>, 'password': <ucsschool.lib.models.attributes.Password object>, 'source_uid': <ucsschool.lib.models.attributes.SourceUID object>, 'school': <ucsschool.lib.models.attributes.SchoolAttribute object>, 'name': <ucsschool.lib.models.attributes.Username object>, 'ucsschool_roles': <ucsschool.lib.models.attributes.Roles object>, 'school_classes': <ucsschool.lib.models.attributes.SchoolClassesAttribute object>, 'email': <ucsschool.lib.models.attributes.Email object>}
_meta = <ucsschool.lib.models.meta.UCSSchoolHelperOptions object>
logger = <Proxy at 0x7fc545627710 wrapping <celery.utils.log.ProcessAwareLogger object> at 0x7fc5452e48d0 with factory <function <lambda>>>
class ucsschool.importer.legacy.legacy_import_user.LegacyImportTeacher(name=None, school=None, **kwargs)[source]

Bases: ucsschool.importer.legacy.legacy_import_user.LegacyImportUser, ucsschool.importer.models.import_user.ImportTeacher

Create ImportUser object (neither saved nor loaded from LDAP yet). The dn attribute is calculated.

Parameters:
  • name (str) – username
  • school (str) – OU
  • kwargs – attributes to set on user object
_attributes = {'firstname': <ucsschool.lib.models.attributes.Firstname object>, 'lastname': <ucsschool.lib.models.attributes.Lastname object>, 'disabled': <ucsschool.lib.models.attributes.Disabled object>, 'birthday': <ucsschool.lib.models.attributes.Birthday object>, 'record_uid': <ucsschool.lib.models.attributes.RecordUID object>, 'schools': <ucsschool.lib.models.attributes.Schools object>, 'password': <ucsschool.lib.models.attributes.Password object>, 'source_uid': <ucsschool.lib.models.attributes.SourceUID object>, 'school': <ucsschool.lib.models.attributes.SchoolAttribute object>, 'name': <ucsschool.lib.models.attributes.Username object>, 'ucsschool_roles': <ucsschool.lib.models.attributes.Roles object>, 'school_classes': <ucsschool.lib.models.attributes.SchoolClassesAttribute object>, 'email': <ucsschool.lib.models.attributes.Email object>}
_meta = <ucsschool.lib.models.meta.UCSSchoolHelperOptions object>
logger = <Proxy at 0x7fc5456276c8 wrapping <celery.utils.log.ProcessAwareLogger object> at 0x7fc5452e48d0 with factory <function <lambda>>>
class ucsschool.importer.legacy.legacy_import_user.LegacyImportTeachersAndStaff(name=None, school=None, **kwargs)[source]

Bases: ucsschool.importer.legacy.legacy_import_user.LegacyImportUser, ucsschool.importer.models.import_user.ImportTeachersAndStaff

Create ImportUser object (neither saved nor loaded from LDAP yet). The dn attribute is calculated.

Parameters:
  • name (str) – username
  • school (str) – OU
  • kwargs – attributes to set on user object
_attributes = {'firstname': <ucsschool.lib.models.attributes.Firstname object>, 'lastname': <ucsschool.lib.models.attributes.Lastname object>, 'disabled': <ucsschool.lib.models.attributes.Disabled object>, 'birthday': <ucsschool.lib.models.attributes.Birthday object>, 'record_uid': <ucsschool.lib.models.attributes.RecordUID object>, 'schools': <ucsschool.lib.models.attributes.Schools object>, 'password': <ucsschool.lib.models.attributes.Password object>, 'source_uid': <ucsschool.lib.models.attributes.SourceUID object>, 'school': <ucsschool.lib.models.attributes.SchoolAttribute object>, 'name': <ucsschool.lib.models.attributes.Username object>, 'ucsschool_roles': <ucsschool.lib.models.attributes.Roles object>, 'school_classes': <ucsschool.lib.models.attributes.SchoolClassesAttribute object>, 'email': <ucsschool.lib.models.attributes.Email object>}
_meta = <ucsschool.lib.models.meta.UCSSchoolHelperOptions object>
logger = <Proxy at 0x7fc545627638 wrapping <celery.utils.log.ProcessAwareLogger object> at 0x7fc5452e48d0 with factory <function <lambda>>>

ucsschool.importer.legacy.legacy_new_user_password_csv_exporter module

Write the passwords of newly created users to a CSV file.

class ucsschool.importer.legacy.legacy_new_user_password_csv_exporter.LegacyNewUserPasswordCsvExporter(*arg, **kwargs)[source]

Bases: ucsschool.importer.writer.new_user_password_csv_exporter.NewUserPasswordCsvExporter

Export passwords of new users to a CSV file.

Recreate line from legacy import script: OUTFILE.write(“%s %s %s” % (person.login, password, line))

field_names = ('username', 'password', 'action', 'name', 'lastname', 'firstname', 'school', 'school_classes', 'ignore', 'email', 'is_teacher', 'activate', 'is_staff')
get_writer()[source]

Change to CSV dialect with tabs and don’t write a header line.

serialize(user)[source]

ucsschool.importer.legacy.legacy_user_import module

Legacy mass import class.

class ucsschool.importer.legacy.legacy_user_import.LegacyUserImport(dry_run=True)[source]

Bases: ucsschool.importer.mass_import.user_import.UserImport

Parameters:dry_run (bool) – set to False to actually commit changes to LDAP
detect_users_to_delete()[source]

No need to compare input and LDAP. Action was written in the CSV file and is already stored in user.action.

determine_add_modify_action(imported_user)[source]

Determine what to do with the ImportUser. Should set attribute “action” to either “A” or “M”. If set to “M” the returned user must be a opened ImportUser from LDAP. Run modify preparations here, like school-move etc.

Parameters:imported_user (ImportUser) – ImportUser from input
Returns:ImportUser with action set and possibly fetched from LDAP
Return type:ImportUser

ucsschool.importer.legacy.legacy_user_import_cmdline module

UCS@school legacy import tool cmdline frontend.

class ucsschool.importer.legacy.legacy_user_import_cmdline.LegacyUserImportCommandLine[source]

Bases: ucsschool.importer.frontend.user_import_cmdline.UserImportCommandLine

parse_cmdline()[source]
configuration_files

Add legacy user import specific configuration files.

Returns:list of filenames
Return type:list(str)
do_import()[source]

ucsschool.importer.legacy.legacy_user_import_parse_cmdline module

Legacy command line frontend for user import.

class ucsschool.importer.legacy.legacy_user_import_parse_cmdline.LegacyUserImportParseUserImportCmdline[source]

Bases: ucsschool.importer.frontend.parse_user_import_cmdline.ParseUserImportCmdline

parse_cmdline()[source]