Fast tools for programming
Project description
mblibs
Fast tools for programming
installation
$ pip install mblibs
Usage for settings
# Using settings
from mblibs.fast import FastSettings
settings = FastSettings("/path/to/yaml_or_json")
value = settings.get("/path/to/key", "default_value")
integer = settings.getInt("/path/to/keyInt", 12)
# => 18/07/2018
date = settings.getWithDateFormat("/path/to/current_date", "{dd}/{mm}/{yyyy}")
# => 19/07/2018
date = settings.getWithDateFormat("/path/to/tomorrow_date"
"{tomorrow_dd}/{tomorrow_mm}/{tomorrow_yyyy}")
# => 17/07/2018
date = settings.getWithDateFormat("/path/to/yesterday_date",
"{yesterday_dd}/{yesterday_mm}/{yesterday_yyyy}")
# sample
{'data': [{'ident': 'name1', 'rows': [{'key': 1}, {'key': 2}]},
{'ident': 'name2', 'rows': [{'key': 3}, {'key': 4}]}]}
settings.get("/data[1]/rows[0]/key") => 3
settings.get("/data[0]/rows") => [{'key': 1}, {'key': 2}]
Usage for email
# Using email object
from mblibs.fast import FastEmail
# email body
body = """
<p>Lorem <em><strong>ipsum</strong></em> dolor !</p>
<p>Ceci est un message de test de l'application</p>
<img class="picture" src="cid:graphic1" alt="Graphique en pièce jointe" />
<p>Merci pour le graphique <br />
Mick</p>
<img class="picture" src="cid:graphic2" alt="Graphique en pièce jointe" />
"""
# init email object
mailer = FastEmail()
mailer.mail_from = settings.get("/smtp/mail_from")
mailer.mail_subject = "A subject for the mail."
mailer.mail_text = 'Merci de lire le message depuis un lecteur acceptant le HTML.'
mailer.mail_html = body
mailer.smtp_host = "localhost"
mailer.smtp_port = 25
mailer.smtp_tls = False
mailer.smtp_login = ""
mailer.smtp_password = ""
# send email
To = ["mail1@mail.mx", "mail2@mail.mx"]
Cc = ["mail3@mail.mx"]
Bcc = ["mail4@mail.mx", "mail5@mail.mx"]
filename = "./ridev.png"
ret = mailer.send_mail(to=To, cc=Cc, bcc=Bcc, attachfiles=[filename],
embeddedimages_tag="graphic",
embeddedimages=["./python.png", filename])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mblibs-1.1.2.tar.gz
(12.6 kB
view details)
File details
Details for the file mblibs-1.1.2.tar.gz
.
File metadata
- Download URL: mblibs-1.1.2.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f55bb1814e86bcde49f84af2bf01270971b923f124c3fa2d57208bbe371a815 |
|
MD5 | 8600fd2483c9741d5b72b8c980d9e1f6 |
|
BLAKE2b-256 | fd2f59365e362e2aad0b5c29a38f73b2ad6499d00ae0e2ecba4555fc0d59b49a |