You can extend Honcho's export capabilities by writing plugins. Honcho discovers plugins via the honcho_exporters setuptools entry point.
Implementation Requirements
To create an exporter, you must:
- Inherit from
honcho.export.base.BaseExport. - Implement a
get_template_loader method. - Implement a
render(self, processes, context) method.
Inside render, you can fetch templates using the get_template method.
Template Overriding
If your exporter inherits from BaseExport, users can override your default templates by passing the --template-dir option to the honcho export command.
import jinja2
from honcho.export.base import BaseExport
class SimpleExport(BaseExport):
def get_template_loader(self):
return jinja2.PackageLoader(package_name=__package__,
package_path='templates')
def render(self, processes, context):
tpl = self.get_template('run.sh')
for p in processes:
filename = 'run-{0}.sh'.format(p.name)
ctx = context.copy()
ctx['process'] = p
script = tpl.render(ctx)