pyprediktorutilities package
Subpackages
Submodules
pyprediktorutilities.file_transfer module
pyprediktorutilities.send_email module
- class pyprediktorutilities.send_email.SendEmail(server: str, port: int, username: str, password: str)[source]
Bases:
object
Helper function to send emails with attachments using SMTP
- Parameters:
- Returns:
SendEmail object
- Return type:
Object
pyprediktorutilities.singleton module
pyprediktorutilities.templating module
- class pyprediktorutilities.templating.Templating(path: str)[source]
Bases:
object
Simple wrapper around a templating engine, allowing for easy rendering of templates such as XMLs and HTMLs. Build on top of Jinja2
- Parameters:
path (str) – The path to the folder containing the templates
- env
The environment to use for rendering
- Type:
jinja2.Environment
- Raises:
FileNotFoundError – If the folder does not exist
FileNotFoundError – If the template does not exist
Exception – If the template could not be rendered
Examples
>>> from pyprediktorutilities.templating import Templating >>> templating = Templating('templates') >>> templates = templating.list_templates() >>> template = templating.load_template('base.html') >>> rendered_template = templating.render(template, title='Home') >>> templating.render_to_file(template, 'output.html', title='Home')
- load_template(template: str) object [source]
Loads a template from the folder
- Parameters:
template (str) – The file name of the template to load
- Raises:
FileNotFoundError – If the template does not exist
- Returns:
The template object
- Return type:
- render(template: str, **kwargs) str [source]
Render a template with the given arguments and return a string