Main class¶
-
class
NaMi
(config={}, **kwargs)[source]¶ Main class for communication with the DPSG NaMi
Example
from pynami.nami import NaMi from pynami.tools import tabulate2x with NaMi(username='MITGLIEDSNUMMER', password='PASSWORD') as nami: print(tabulate2x(nami.search()))
Parameters: config ( dict
, optional) – Authorization configuration-
_check_response
(response)[source]¶ Check a requests response object if the NaMi response looks ok. This currently checks some very basic things.
Raises: NamiHTTPError
– When HTTP communication failesNamiResponseSuccessError
– When the NaMi returns an error
-
_get_baseadmin
(key, grpId=None, mglId=None, taetigkeitId=None, **kwargs)[source]¶ Base function for retrieving all core lists from the NaMi
Parameters: - key (
str
) – Name of the wanted items - grpId (
int
orstr
, optional) – Group id - mglId (
int
orstr
, optional) – Member id (not the DPSG Mitgliedsnummer) - taetigkeitId (
int
, optional) – Id of an activity. A list of all possible ids can be found in the section Activity types. This is only required for the URLs which needs to be formatted with this value.
Keyword Arguments: Returns: The returned default values
Return type: - key (
-
auth
(username=None, password=None)[source]¶ Authenticate against the NaMi API. This stores the jsessionId cookie in the requests session. Therefore this needs to be called only once.
This also stores your id (not the Mitgliednummer) for later pruposes.
Parameters: Returns: The requests session, including the auth cookie
Return type:
-
beitragsarten
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: Each possible fee type
Return type:
-
beitragsarten_mgl
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: Each possible fee for a member
Return type:
-
bescheinigungen
(**kwargs)[source]¶ Get all certificates of inspection
Returns: A list of all your certificates of inspection Return type: list
ofSearchBescheinigung
-
countries
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: List of all possible countries with their names and ids
Return type:
-
download_beantragung
(**kwargs)[source]¶ Open the application form for a certificate of good conduct as a PDF file.
Parameters: **kwargs – See open_download_pdf()
.
-
download_bescheinigung
(id_, **kwargs)[source]¶ Open a certificate as a PDF file
Parameters: - id (int) – Internal id of the certificate
- **kwargs – See
open_download_pdf()
.
-
download_invoice
(id_, **kwargs)[source]¶ Downloads and opens an invoice as a pdf document.
Parameters: - id (int) – Id of the invoice (not the regular invoice number)
- **kwargs – See
open_download_pdf()
.
-
ebene2
(ebene1)[source]¶ You can choose a Bezirk which you belong to.
Parameters: ebene1 (int) – Group id of a Diözese Returns: List of possible Bezirken you are associated with Return type: list
ofBaseadmin
-
ebene3
(ebene2)[source]¶ You can choose a Stamm which you belong to.
Parameters: ebene2 (int) – Group id of a Bezirk Returns: List of possible Stämmen you are associated with Return type: list
ofBaseadmin
-
geschlechter
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: You can choose between three genders: male, female and diverse.
Return type:
-
get_activity
(mgl, id_)[source]¶ Get an activity by its id.
Parameters: - mgl (int) – Member id (not DPSG Mitgliedsnummer)
- id (int) – Id of the activity. This will probably originate from an
activity search result, e.g. by calling
mgl_activities()
.
Returns: The Activity object containing all details.
Return type:
-
get_ausbildung
(mglId, id_)[source]¶ Get a training by its id.
Parameters: - mglId (int) – Member id (not DPSG Mitgliedsnummer)
- id (int) – Id of the training. This will probably originate from an
training search result, e.g. by calling
mgl_ausbildungen()
.
Returns: The Ausbildung object containing all details about the training.
Return type:
-
get_bescheinigung
(id_)[source]¶ View a certificate of inspection by its id
Parameters: id (int) – The internal id of the certificate Returns: An object holding all important details about the inspection Return type: Bescheinigung
-
get_mgl_history
(mglId, id_, ext=True)[source]¶ Get a member history entry by its id.
Parameters: - mglId (int) – Member id (not DPSG Mitgliedsnummer)
- id (int) – Id of the entry. May originate from a search result,
e.g. by calling
mgl_history()
. - ext (
bool
, optional) – If the extended history format should be used. Defaults toTrue
.
Returns: The object containing all vital information about this history entry.
Return type:
-
get_tag
(mglId, tagId)[source]¶ Get a tag by its id
Parameters: Returns: The tag object with all important details
Return type:
-
grpId
¶ Group id of the user
Returns: int
-
grpadmin_grps
¶ Choose from a list of groups that you are associated with for group admin
Type: list
ofBaseadmin
-
gruppierungen
¶ Choose from a list of groups that you are associated with for member admin
Type: list
ofBaseadmin
-
history
(**kwargs)[source]¶ Dashboard function
Returns: Last editing events like updating and creating members.In the NaMi these are displayed in the dashboard. Return type: list
ofHistoryEntry
-
invoice
(groupId, invId)[source]¶ Get an invoice by its id.
Parameters: - groupId (int) – Group id
- invId (int) – Id of the invoice. This will probably originate from
a search result, e.g. by calling
invoices()
.
Returns: The Invoice object containing all details.
Return type:
-
invoices
(groupId=None, **kwargs)[source]¶ List of all invoices of a group
Parameters: groupId ( int
, optional) – Group idReturns: All invoices of the specified group Return type: list
ofSearchInvoice
-
konfessionen
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: All denominations
Return type:
-
logout
()[source]¶ This should be called at the end of the communication. It is called when exiting through the
__exit__()
method.
-
mgl_activities
(mgl)[source]¶ List of all activities of a member
Parameters: mgl (int) – Member id (not DPSG Mitgliedsnummer) Returns: All activities of the member (even those which have already ended) Return type: list
ofActivity
-
mgl_ausbildungen
(mglId)[source]¶ Get all trainings from a Mitglied.
Parameters: mglId (int) – Member id (not DPSG Mitgliedsnummer) Returns: All trainings of the member Return type: list
ofSearchAusbildung
-
mgl_history
(mglId, ext=True)[source]¶ Get all history changes from a Mitglied.
Parameters: Returns: All history entries of the member
Return type: list
ofHistoryEntry
-
mgltypes
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: You can have one of three different member types
Return type:
-
mitglied
(mglId=None, method='GET', grpId=None, **kwargs)[source]¶ Gets or updates a Mitglied.
The keyword arguments are passed on to the HTTP communication
Parameters: - mglId (
int
, optional) – ID of the Mitglied. This is not the DPSG Mitgliedsnummer. Defaults to the user. - method (
str
) – HTTP Method. Should be'GET'
or'PUT'
, defaults to'GET'
. - grpId (
int
, optional) – The DPSG Stammesnummer, e.g.131913
. The default (None
) takes the value from the internal attribute__config
.
Returns: The retrieved or respectively updated Mitglied. Note that the
austrittsDatum
attribute is not part of the returned data set.Return type: - mglId (
-
myId
¶ NaMi internal id of the user
Returns: int
-
notifications
(sortproperty=None, sortdirection='ASC', **kwargs)[source]¶ Dashboard function
Returns: All current notifications (like tier changes of members). In the NaMi these are displayed in the dashboard. Return type: list
ofNotification
-
regionen
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: All possible Bundeslaender
Return type:
-
search
(**kwargs)[source]¶ Run a search for members
Todo
- Check search terms and formatting. Also some search keys can only be used mutually exclusive.
Parameters: **kwargs – Search keys and words. Be advised that some search words must have a certain formatting or can only take a limited amount of values. Returns: The search results Return type: list
ofSearchMitglied
See also
SearchSchema
for a complete list of search keys
-
search_all
(grpId=None, filterString=None, searchString='', sortproperty=None, sortdirection='ASC', **kwargs)[source]¶ Search function for filtering the whole member list with limited filter options.
It is also possible to sort the results.
Parameters: - filterString (
str
, optional) – Filter attribute. - searchString (
str
, optional) – You can search within the chosen filter attribute. The Format must match the type of the filter attribute. - sortproperty (
str
, optional) – Attribute by wich the results shall be sorted. - sortdirection (
str
, optional) – Direction of sorting. Can take the valuesASC
(wich is the default) andDESC
.
Returns: The search results
Return type: - filterString (
-
staaten
(grpId=None, mglId=None)[source]¶ Get default values
Parameters: Returns: A quite long list of different nationalities
Return type:
-
stats
¶ Contains counts from different tiers. The actual list of
StatCategory
is in thestatsCategories
attribute.Type: Stats
-
subdivision
¶ Which division you are associated with. This one is only used for searching.
Type: list
ofBaseadmin
-
tagList
¶ A different list of fee types but with basically the same content. This one is used for searching members.
Deprecated since version 0.3.3: Only returns an empty list and has therefore become useless.
Type: list
ofBaseadmin
Get all tags of a member
Parameters: mglId (int) – Member id (not DPSG Mitgliedsnummer) Returns: List of the search results Return type: list
ofSearchTag
-
tk_auf_grp
(grpId, mglId, **kwargs)[source]¶ Get all possible activities for a certain group
Parameters: Returns: List of possible activities
Return type:
-
tk_caea_grp
(grpId, mglId, taetigkeitId, **kwargs)[source]¶ Get all possible access rights for an activity
Parameters: Returns: List of possible access rights
Return type:
-
tk_grp
(grpId, mglId, **kwargs)[source]¶ Get all possible groups for an activity
Parameters: Returns: List of possible groups
Return type:
-
tk_ug
(grpId, mglId, taetigkeitId, **kwargs)[source]¶ Get all possible subdivision for an activity
Parameters: Returns: List of possible subdivision
Return type:
-
update_activity
(mgl, act)[source]¶ Update an activity
Parameters: Returns: A new updated object
Return type: Warning
This has not been tested yet!
-
update_ausbildung
(mglId, ausbildung)[source]¶ Update a training
Parameters: - mgl (int) – Member id (not DPSG Mitgliedsnummer)
- ausbildung (
Ausbildung
) – Updated data set. The training id is taken form this data set.
Returns: A new updated object
Return type: Warning
This has not been tested yet!
-