Usage¶
The package should be quite comfortable to use without loosing flexibility.
Authentification¶
from pynami.nami import NaMi
with NaMi(username='MITGLIEDSNUMMER', password='PASSWORD') as nami:
pass
from pynami.nami import NaMi
nami = NaMi()
nami.auth(username='MITGLIEDSNUMMER', password='PASSWORD')
# do stuff
nami.logout()
Access default values¶
from pynami.tools import tabulate2x
print(tabulate2x(nami.geschlechter()))
Get a specific mitglied¶
id_ = nami.search(vorname='Max', nachname='Mustermann')[0].id
mgl = nami.mitglied(id_)
print(mgl.mitgliedsNummer)
Search for a group of members¶
search = {
'mglStatusId': 'AKTIV',
'mglTypeId': 'MITGLIED',
'untergliederungId': [2, 3],
'taetigkeitId': 1
}
result = nami.search(**search)
print(tabulate2x(result))
Send emails¶
from pynami.tools import send_emails
send_emails(result)
Export data¶
There are two functions for exporting data. The first is to export the data as a CSV formatted string and save that as a file using the method make_csv()
.
from pynami.tools import make_csv
keys = ['mitgliedsNummer', 'vorname', 'nachname', 'geschlecht', 'geburtsDatum']
with open('data.csv', 'w', newline='', encoding='utf-8-sig') as f:
f.writelines(make_csv(result, keys, delimiter=';'))
Another option is to export the data as an Excel file using the function export_xlsx()
which comes already with a possible write to file functionality.
from pynami.tools import export_xlsx
export_xlsx(result, keys, write_to_file=True, filepath='data.xlsx')