import sys

from piecash_utilities.report import report, execute_report


@report(
    title="My simplest report",
    name="piecash-simple-report",
    menu_tip="This simple report ever",
    options_default_section="general",
)
def generate_report(
        book_url,
):
    return "<html><body>Hello world from python !</body></html>"


if __name__ == '__main__':
    execute_report(generate_report, book_url=sys.argv[1])
Пример #2
0
from piecash_utilities.report import report, execute_report


@report(
    title="My simplest report with a book",
    name="piecash-simple-report-book",
    menu_tip="A simple report that opens a book",
    options_default_section="general",
)
def generate_report(book_url):
    """
    Generates the report HTML.
    """
    with piecash.open_book(book_url, readonly=True, open_if_lock=True) as book:
        accounts = [acc.fullname for acc in book.accounts]

        return f"""<html>
        <body>
            Hello world from python !<br>
            Book : {book_url}<br>
            List of accounts : {accounts}
        </body>
        </html>"""

if __name__ == '__main__':
    book_url = None
    if len(sys.argv) > 1:
        book_url = sys.argv[1]
    execute_report(generate_report, book_url)
Пример #3
0
    a_str: StringOption(section="main",
                        sort_tag="c",
                        documentation_string="This is a string",
                        default_value="with a default value"),
    a_date: DateOption(
        section="main",
        sort_tag="d",
        documentation_string="This is a date",
        default_value="(lambda () (cons 'absolute (cons (current-time) 0)))"),
    another_number: RangeOption(section="main",
                                sort_tag="b",
                                documentation_string="This is a number",
                                default_value=3)):
    import piecash

    with piecash.open_book(uri_conn=book_url, readonly=True,
                           open_if_lock=True) as b:

        tpl_name = os.path.basename(__file__).replace("py", "html")
        env = jinja2.Environment(loader=jinja2.PackageLoader(__name__, '.'))

        return env.get_template(tpl_name).render(
            enumerate=enumerate,
            list=list,
            path_report=os.path.abspath(__file__),
            **vars())


if __name__ == '__main__':
    execute_report(generate_report, sys.argv[1])
Пример #4
0
import piecash
import sys

from piecash_utilities.report import report, execute_report


@report(
    title="My simplest report with a book",
    name="piecash-simple-report-book",
    menu_tip="A simple report that opens a book",
    options_default_section="general",
)
def generate_report(
        book_url,
):
    with piecash.open_book(book_url, readonly=True, open_if_lock=True) as book:
        return """<html>
        <body>
            Hello world from python !<br>
            Book : {book_url}<br>
            List of accounts : {accounts}
        </body>
        </html>""".format(
            book_url=book_url,
            accounts=[acc.fullname for acc in book.accounts],
        )


if __name__ == '__main__':
    execute_report(generate_report, book_url=sys.argv[1])
            documentation_string="This is a string",
            default_value="with a default value"),
        a_date: DateOption(
            section="main",
            sort_tag="d",
            documentation_string="This is a date",
            default_value="(lambda () (cons 'absolute (cons (current-time) 0)))"),
        another_number: RangeOption(
            section="main",
            sort_tag="b",
            documentation_string="This is a number",
            default_value=3)
):
    import piecash

    with piecash.open_book(uri_conn=book_url, readonly=True, open_if_lock=True) as b:

        tpl_name = os.path.basename(__file__).replace("py", "html")
        env = jinja2.Environment(loader=jinja2.PackageLoader(__name__, '.'))

        return env.get_template(tpl_name).render(
            enumerate=enumerate,
            list=list,
            path_report=os.path.abspath(__file__),
            **vars()
        )


if __name__ == '__main__':
    execute_report(generate_report, sys.argv[1])