Skip to content

Instantly share code, notes, and snippets.

@robintw
Created September 18, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robintw/1d8210859ab4b5302ea66c953288bd51 to your computer and use it in GitHub Desktop.
Save robintw/1d8210859ab4b5302ea66c953288bd51 to your computer and use it in GitHub Desktop.
List patched functions in recipy
import recipy
import pprint
from tinydb import TinyDB
from jinja2 import Template
from recipyCommon.utils import open_or_create_db
db = open_or_create_db()
modules = db.table('patches').all()
db.close()
template = Template(r"""
<div class="row">
<div class="col-md-12">
<h1>Patched modules</h1>
{% if modules | length > 0 %}
<p>This table lists the modules recipy has patches for, and the input and output functions that are patched.</p>
<table class="table table-hover">
<thead>
<tr>
<th>Module</th>
<th>Input functions</th>
<th>Output functions</th>
</tr>
</thead>
{% for mod in modules %}
<tr>
<td><code>{{ mod.modulename }}</code></td>
<td>
{% if mod.input_functions | length > 0 %}
<code>{{ mod.input_functions|join('</code>, <code>')|safe }}</code>
{% endif %}
</td>
<td>
{% if mod.output_functions | length > 0 %}
<code>{{ mod.output_functions|join('</code>, <code>')|safe }}</code>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}
No patched modules found. Please <code>import recipy</code> to register available patches.
{% endif %}
</div>
</div>
""")
result = template.render(modules=modules)
with open('patched_modules.html', 'w') as f:
f.write(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment