|
Revision 145:ef9737d0a7db, 0.9 kB
(checked in by C?dric Krier <ced@…>, 4 years ago)
|
|
Allow to run examples from anywhere
Force the output of examples in the same directory
|
| Line | |
|---|
| 1 | from os.path import abspath, join, dirname |
|---|
| 2 | from relatorio import Report |
|---|
| 3 | |
|---|
| 4 | # test data |
|---|
| 5 | from common import inv |
|---|
| 6 | |
|---|
| 7 | if __name__ == '__main__': |
|---|
| 8 | pie_report = Report(abspath(join(dirname(__file__), 'pie_chart')), |
|---|
| 9 | 'image/png') |
|---|
| 10 | file(join(dirname(__file__), 'pie.png'), 'wb').write( |
|---|
| 11 | pie_report(o=inv).render().getvalue()) |
|---|
| 12 | hbar_report = Report(abspath(join(dirname(__file__), 'hbar_chart')), |
|---|
| 13 | 'image/svg') |
|---|
| 14 | file(join(dirname(__file__), 'hbar.svg'), 'wb').write( |
|---|
| 15 | hbar_report(o=inv).render().getvalue()) |
|---|
| 16 | vbar_report = Report(abspath(join(dirname(__file__), 'vbar_chart')), |
|---|
| 17 | 'image/svg') |
|---|
| 18 | file(join(dirname(__file__), 'vbar.svg'), 'wb').write( |
|---|
| 19 | vbar_report(o=inv).render().getvalue()) |
|---|
| 20 | line_report = Report(abspath(join(dirname(__file__), 'line_chart')), |
|---|
| 21 | 'image/png') |
|---|
| 22 | file(join(dirname(__file__), 'line.png'), 'wb').write( |
|---|
| 23 | line_report(o=inv).render().getvalue()) |
|---|