pynami.schemas package¶
Submodules¶
pynami.schemas.activity module¶
Schemas for activities
-
class
Activity
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class for activities directly obtained by their id.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
ActivitySchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
Activity
class
-
class
SearchActivity
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Main class for activities wich come up as a search result.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
SearchActivitySchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
SearchActivity
class-
__model__
¶ alias of
SearchActivity
-
pynami.schemas.base module¶
This module contains some base classes
-
exception
AccessError
[source]¶ Bases:
AttributeError
-
class
BaseModel
(**kwargs)[source]¶ Bases:
object
Base class for all the main classes.
It stores all data entries as instance attributes.
-
__getstate__
()[source]¶ Enable saving data through pickling
Returns: Returns the __dict__
attribute of the class.Return type: dict
-
__setattr__
(name, value)[source]¶ Set certain fields to read-only
Parameters: - name (str) – Attribute name.
- value – New value.
Raises: AccessError
– In case of invalid write access.Returns:
-
__setstate__
(state)[source]¶ Enable loading data with the
pickle
moduleParameters: state (dict) – Loaded data. Returns: None
-
_field_blacklist
= []¶ Attribute names which are to be skipped while preparing tabulated output
Type: list
-
_tabkeys
= []¶ Default attributes names for tabulating and data export. This attribute is inherited and adapted to all Schema classes from
BaseModel
.Type: list
ofstr
-
table_view
(field_blacklist=None)[source]¶ Prepare nicely formatted output
Parameters: field_blacklist ( list
ofstr
, optional) – List of attributes to be skippedReturns: All data entries which are not in the blacklist Return type: dict
-
tabulate
(elements=None)[source]¶ Prepare ordered tabulated output
Parameters: elements ( list
ofstr
, optional) – List of keys which shall be included in the tableReturns: Specified data entries Return type: OrderedDict
-
-
class
BaseSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
marshmallow.schema.Schema
Base class for all Schemas in this module
It handles the formatting of dates so that the fields in the derived classes can be standard
DateTime
field.Note
This class can not be used on its own but only as a derived class.
-
class
Meta
[source]¶ Bases:
object
This Base Meta class defines the default date and time format.
-
__model__
¶ class: Main class which this Schema is modelling. Each derived class must define this attribute.
alias of
BaseModel
-
_declared_fields
= {}¶
-
_hooks
= {('post_load', False): ['make_object'], ('pre_load', False): ['correctEmptySTrings']}¶
-
correctEmptySTrings
(data, **kwargs)[source]¶ Replace empty strings with
None
This method loops over all fields of the derived Schema class and where it finds a
DateTime
field and an empty string in the datadict
it replaces this value withNone
.To achieve that this is applied before loading this method is decorated with
pre_load()
decorator.Parameters: data (dict) – Data dictionary which is about to be loaded Returns: Adjusted data dictionary Return type: dict
-
make_object
(data, **kwargs)[source]¶ Create the object associated with this Schema by making use of the
post_load()
decorator.Parameters: - data (dict) – Data dictionary containing all keywords and their values
- **kwargs – Possible keyword arguments passed through to this method during the loading procedure.
Returns: Main class correspoding to this Schema
Return type:
-
class
-
class
BaseSearchModel
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Base class for all classes that are loaded from a
BaseSearchSchema
-
_tabkeys
= ['id', 'descriptor']¶
-
-
class
BaseSearchSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Base class for all schemas that describe search results.
All search results share the same three attributes.
-
__model__
¶ alias of
BaseSearchModel
-
_declared_fields
= {'descriptor': <fields.String(dump_default=<marshmallow.missing>, attribute=None, validate=None, required=False, load_only=False, dump_only=False, load_default=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.', 'invalid': 'Not a valid string.', 'invalid_utf8': 'Not a valid utf-8 string.'})>, 'id': <fields.Raw(dump_default=<marshmallow.missing>, attribute=None, validate=None, required=False, load_only=False, dump_only=False, load_default=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.'})>, 'representedClass': <fields.String(dump_default=<marshmallow.missing>, attribute=None, validate=None, required=False, load_only=False, dump_only=False, load_default=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.', 'invalid': 'Not a valid string.', 'invalid_utf8': 'Not a valid utf-8 string.'})>}¶
-
_hooks
= {('post_load', False): ['make_object'], ('pre_load', False): ['correctEmptySTrings']}¶
-
descriptor
= None¶ Object description. In some cases the same as
representedClass
.Type: str
-
pynami.schemas.cogc module¶
This module contains classes to handle stuff with the certificates of good conduct.
-
class
Bescheinigung
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Base data class for a certificate about the inspection of a certificate of goos conduct.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
download_fz
(nami, **kwargs)[source]¶ Open the certificate as a PDF file
Parameters: - nami (
NaMi
) – Main NaMi class - **kwargs – See
open_download_pdf()
.
Returns: - nami (
-
-
class
BescheinigungSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
Bescheinigung
class-
__model__
¶ alias of
Bescheinigung
-
-
class
SearchBescheinigung
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Base data class for a certificate about the inspection of a certificate of goos conduct that came up as a search result.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
download_fz
(nami, **kwargs)[source]¶ Open the certificate as a PDF file
Parameters: - nami (
NaMi
) – Main NaMi class - **kwargs – See
open_download_pdf()
.
Returns: - nami (
-
get_bescheinigung
(nami)[source]¶ Create a real
Bescheinigung
form the search result by getting the corresponding data set through the certificate id.Parameters: nami ( NaMi
) – Main NaMi classReturns: The certificate object corresponding to this search result. Return type: Bescheinigung
-
-
class
SearchBescheinigungSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
SearchBescheinigung
class-
__model__
¶ alias of
SearchBescheinigung
-
pynami.schemas.dashboard module¶
Schemas for dashboard functionalities
-
class
Notification
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Main class for notification like tier changes of a mitglied.
In the NaMi the notifications are displayed in the dashboard.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
NotificationSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
Notification
class-
__model__
¶ alias of
Notification
-
-
class
StatCatSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
StatCategory
class.This only contains the name of the tier and its number of members.
-
__model__
¶ alias of
StatCategory
-
-
class
StatCategory
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class for statistical tier numbers.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
Stats
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class for basic statistical entries.
The information in this class is displayed in the NaMi dashboard in a pie chart.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
StatsSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
Stats
class-
statsCategories
= None¶ Detailed information on the partitions
Type: list
ofStatCategory
-
pynami.schemas.default module¶
Schema for default values
-
class
Baseadmin
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Base data class for all default values and their id mapping.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
BaseadminSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
Baseadmin
classAll the default values only consist of the same four attributes
pynami.schemas.grpadmin module¶
This module contains classes for group admin (Gruppierungsverwaltung) stuff
-
class
Invoice
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Repesents an invoice
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
download
(nami, **kwargs)[source]¶ Download this invoice as PDF
Parameters: - nami (
NaMi
) – Main NaMi class - **kwargs – See
open_download_pdf()
.
Returns: - nami (
-
-
class
InvoiceSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
Invoice
class
-
class
SearchInvoice
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Repesents an invoice that came up as a search result
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
download
(nami, **kwargs)[source]¶ Download this invoice as PDF
Parameters: - nami (
NaMi
) – Main NaMi class - **kwargs – See
open_download_pdf()
.
Returns: - nami (
-
-
class
SearchInvoiceSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
SearchInvoice
class-
__model__
¶ alias of
SearchInvoice
-
pynami.schemas.history module¶
Schemas for history entries
-
class
HistoryEntry
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Main class for history entries
This contains information about an update of a Mitglied which is displayed on the NaMi dashbiard.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
get_history
(nami, mglId, ext=True)[source]¶ Create a real
MitgliedHistory
form the search result by getting the corresponding data set through the history entry id.Parameters: Returns: The activity object corresponding to this search result.
Return type:
-
-
class
HistoryEntrySchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
HistoryEntry
class-
__model__
¶ alias of
HistoryEntry
Who did this
Type: str
-
entries_mitglied
= None¶ Almost the same as
entries_author
Type: str
-
-
class
MitgliedHistory
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class for a member revision history entry obtained directly from its id.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
MitgliedHistorySchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
MitgliedHistory
class-
__model__
¶ alias of
MitgliedHistory
-
pynami.schemas.mgl module¶
Schemas for operations on members
-
class
Mitglied
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class representing a NaMi Mitglied
This class overwrites the
__getattr__()
and__setattr__()
methods so that attributes of this class can be handled in a convenient way. It is intended to be instantiated by calling theload()
method on a corresponding data dictionary.
-
class
MitgliedSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for a
Mitglied
-
class
Meta
[source]¶ Bases:
pynami.schemas.base.Meta
Extended
marshmallow.Schema.Meta
class for further configuration
-
gruppierungId
= None¶ Group id
Note
In the search result (see
SearchMitgliedSchema
) this comes as astr
.Type: int
-
kontoverbindung
= None¶ Account details. In a search result this comes as a
str
.Type: NamiKontoSchema
-
class
-
class
NamiKonto
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Holds information about bank account and payment method of the member.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
NamiKontoSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for bank account and payment method information.
This Schema will be nested inside a
MitgliedSchema
and there should be no other use for it.-
double_dump
(data, **kwargs)[source]¶ Incoming data sets are nicely formatted
json
strings which can be loaded easily into the Schema but when you update a Mitglied all payment details have to formatted into ajson
string and all attributes have to be in a certain order. To achieve this thepost_dump()
decorator is used.Parameters: data (dict) – Already dumped data set Returns: A json
formatted stringReturn type: str
-
id_to_str
(data, **kwargs)[source]¶ For some reason the NaMi gives the id of the payment details as an
integer
, but when you want to update a member it has be astring
. Therefore this method converts incoming ids to astr
object before loading them by making use of thepre_load()
decorator.Parameters: data (dict) – Data dictionary to be loaded Returns: Corrected data dictionary Return type: dict
-
-
class
SearchMitglied
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Main class for a Mitglied which came up as a search result. Unfortunately there cannot be just one Mitglied class because the search results lack crucal imformation (e.g. payment details).
-
class
SearchMitgliedSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for
SearchMitglied
.For some reason attribute naming in the NaMi is a bit inconsistent between a Mitglied which comes up as a search result and one that is addressed directly by its id.
-
__model__
¶ alias of
SearchMitglied
-
entries_emailVertretungsberechtigter
= None¶ Email address of an authorized representative.
Type: str
-
entries_kontoverbindung
= None¶ Account details. For some reason this is not always transmitted and may therefore be empty.
Type: str
-
pynami.schemas.search module¶
This module contains the classes for a search for members
-
class
SearchSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Base class for search parameters
You could just use
json.dumps()
on a dictionary to create the search string but this would bypass all the type and spell checking.This also takes care of the miss-spelled search key
'mitgliedsNummber'
so that the user of this API can use the correct spelling.Example
from pynami.search import SearchSchema searchKeys = {'vorname': 'Max', 'nachname': 'Mustermann'} searchedValues = SearchSchema().dumps(searchKeys, separators=(',', ':')) print(searchedValues)
from pynami.tools import tabulate2x from pynami.nami import NaMi with NaMi(username='MITGLIEDSNUMMER', password='PASSWORD') as nami: searchResults = nami.search(untergliederungId=[1,2]) print(tabulate2x(searchResults))
-
class
Meta
[source]¶ Bases:
pynami.schemas.base.Meta
Extended
marshmallow.Schema.Meta
class for further configuration
-
correct_spelling
(data, **kwargs)[source]¶ Check for missspelled or incorrect data before dumping. Realized by the
pre_dump()
decorator.Parameters: data (dict) – Data set to be dumped Returns: Corrected data Return type: dict Raises: KeyError
– When there is a search key that is not an attribute of this class
-
class
pynami.schemas.training module¶
Schemas for trainings
-
class
Ausbildung
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseModel
Main class for a training obtained directly from its id.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
-
class
AusbildungSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSchema
Schema class for the
Ausbildung
class-
__model__
¶ alias of
Ausbildung
-
-
class
SearchAusbildung
(**kwargs)[source]¶ Bases:
pynami.schemas.base.BaseSearchModel
Main class for a training obtained as a search result.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.-
get_ausbildung
(nami, mglId)[source]¶ Create a real
Ausbildung
form the search result by getting the corresponding data set through the training id.Parameters: Returns: The activity object corresponding to this search result.
Return type:
-
-
class
SearchAusbildungSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
SearchAusbildung
class-
__model__
¶ alias of
SearchAusbildung
-
pynami.schemas.tags module¶
Schemas for tags
Bases:
pynami.schemas.base.BaseSearchModel
Base data class for a tag that came up as a search result.
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.
Bases:
pynami.schemas.base.BaseSearchSchema
Schema class for the
SearchBescheinigung
classalias of
SearchTag
Identity of the member with the DPSG Mitgliedsnummer
Type: str
Actual value of the tag
Type: str
Bases:
pynami.schemas.base.BaseModel
Base data class for a tag
This class is intended to be instantiated by calling the
load()
method on a corresponding data dictionary.