py2html
HTML Converter
- satcfdi.models.py2html.dumps(obj, clubbing=True, escape=True, translate_keys=None, default=<class 'str'>)[source]
Convert object to HTML Table format
- class satcfdi.models.py2html.PY2HTMLEncoder(clubbing=True, escape=True, translate_keys=None, default=<class 'str'>)[source]
Bases:
object- encode(input)[source]
Dispatch JSON input according to the outermost type and process it to generate the super awesome HTML format. We try to adhere to duck typing such that users can just pass all kinds of funky objects to py2html that behave like dicts and lists and other basic JSON types.
- convert_list(list_input)[source]
Iterate over the JSON list and process it to generate either an HTML table or a HTML list, depending on what’s inside. If suppose some key has array of objects and all the keys are same, instead of creating a new row for each such entry, club such values, thus it makes more sense and more readable table.
- @example:
- pyObject = {
- “sampleData”: [
{“a”:1, “b”:2, “c”:3}, {“a”:5, “b”:6, “c”:7}
]
} OUTPUT: _____________________________ | | | | | | | a | c | b | | sampleData |---|—|---| | | 1 | 3 | 2 | | | 5 | 7 | 6 | —————————–
@contributed by: @muellermichel