geonature.core.imports.checks.sql.user

Classes

UserMatchingSchema

Base schema class with which to define schemas.

Functions

user_matching(imprt, field)

Find matching user for a given transient table and csv column.

map_observer_matching(imprt, entity, observer_field)

Module Contents

class geonature.core.imports.checks.sql.user.UserMatchingSchema(*, only: marshmallow.types.StrSequenceOrSet | None = None, exclude: marshmallow.types.StrSequenceOrSet = (), many: bool | None = None, load_only: marshmallow.types.StrSequenceOrSet = (), dump_only: marshmallow.types.StrSequenceOrSet = (), partial: bool | marshmallow.types.StrSequenceOrSet | None = None, unknown: marshmallow.types.UnknownOption | None = None)[source]

Bases: marshmallow.Schema

Base schema class with which to define schemas.

Example usage:

import datetime as dt
from dataclasses import dataclass

from marshmallow import Schema, fields


@dataclass
class Album:
    title: str
    release_date: dt.date


class AlbumSchema(Schema):
    title = fields.Str()
    release_date = fields.Date()


album = Album("Beggars Banquet", dt.date(1968, 12, 6))
schema = AlbumSchema()
data = schema.dump(album)
data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}
Paramètres:
  • only – Whitelist of the declared fields to select when instantiating the Schema. If None, all fields are used. Nested fields can be represented with dot delimiters.

  • exclude – Blacklist of the declared fields to exclude when instantiating the Schema. If a field appears in both only and exclude, it is not used. Nested fields can be represented with dot delimiters.

  • many – Should be set to True if obj is a collection so that the object will be serialized to a list.

  • load_only – Fields to skip during serialization (write-only fields)

  • dump_only – Fields to skip during deserialization (read-only fields)

  • partial – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

Modifié dans la version 3.0.0: Remove prefix parameter.

Modifié dans la version 4.0.0: Remove context parameter.

user_to_match[source]
id_role[source]
identifiant[source]
nom_complet[source]
geonature.core.imports.checks.sql.user.user_matching(imprt: geonature.core.imports.models.TImports, field: geonature.core.imports.models.BibFields)[source]

Find matching user for a given transient table and csv column.

Parameters

imprtTImports

The import object which contains the transient table.

fieldBibFields

field use to fetch user name strings

Returns

dict

A dictionary of users name (as it appears in the source file) as key and a dictionary of matching information as value. The matching information contains id_role, identifiant, nom_complet.

Notes

The matching is done by computing the similarity between the source file usernames and the nom_complet of the users in the utilisateurs.t_roles table.

geonature.core.imports.checks.sql.user.map_observer_matching(imprt: geonature.core.imports.models.TImports, entity: geonature.core.imports.models.Entity, observer_field: geonature.core.imports.models.BibFields)[source]