Mercurial > getan
changeset 526:31282f97b807
Reworked the --help function
* More information about the templates
* Information about the templates and how to
create them added to the README file.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Tue, 22 Jan 2019 15:35:28 +0100 |
parents | bad607aec1af |
children | fab6ff9b248e |
files | README getan/main.py scripts/getan-report |
diffstat | 3 files changed, 82 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/README Thu Jan 17 19:27:07 2019 +0100 +++ b/README Tue Jan 22 15:35:28 2019 +0100 @@ -167,6 +167,74 @@ $ getan /path/to/mytime.db +Writing Templates +================= + +Getan uses the Jinja2 templating language. You can find more information +at `Jinja2 <http://jinja.pocoo.org/>`_. + +If a year or a week is specified, only the entries in this period will be +loaded. + +Variables +--------- + +current_week: The current week. +current_year: The current year. + +user: What You indicated with -u. +week: What You indicated with -w. +unix_week: What You indicated with -w, in unix notation. +year: What you indicated with -y. + +get_total_duration(): Total duration of all entries. + +database: Path of the database. + +entries: List of all entries. + get_comment(): Description of the entry. + get_workpackage(): Work package of the entry. + desc: Work package and Description of the entry. + + startisoday: Year, month and day in ISO format. + start: Start time as datetime. + end: End time as datetime. + get_duration(): Duration of the entry. + +projects: List of all projects. + get_total_duration(): Total duration of all + entries in the project. + desc: Description of the project. + key: Key of the project. + + entries: All entries in this project (See entries). + + +If -w is specified, only this week will be loaded from the database. + +year(): All entries in this year. +month(): All entries in this month. +week(): All entries in this week. +day(): All entries in this day. + +Example +------- + +{{ user }}, (KW {{ week }}, {{ year }}) +{% for i in user -%} += +{%- endfor -%} + ============== +{% for proj in projects %} +# {{ proj.desc }} +{% for entry in proj.entries|sort(attribute='start') -%} +{{ entry.get_comment() }} +{% endfor -%} +# total time: {{ proj.get_total_duration()|human_time }}h +{% endfor %} +# total: {{ total_time|human_time }}h + + CREDITS ======= Getan is Free Software licensed under the terms of GNU GPL v>=3.
--- a/getan/main.py Thu Jan 17 19:27:07 2019 +0100 +++ b/getan/main.py Tue Jan 22 15:35:28 2019 +0100 @@ -47,11 +47,12 @@ ''' % getan.__version__ parser = argparse.ArgumentParser(prog='getan', usage=usage, - formatter_class=argparse.RawTextHelpFormatter) + description="You can find more information at https://pypi.org/project/getan/", + formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--version', action='version', version=textwrap.dedent(version)) parser.add_argument(dest='filename', nargs='?', - help='[databasefile (default: %(default)s)]', + help='[databasefile (default: ~/.getan/%(default)s)]', default=DEFAULT_DATABASE) parser.add_argument('--init-only', action='store_true', dest='initonly', help='create databasefile if necessary and exit')
--- a/scripts/getan-report Thu Jan 17 19:27:07 2019 +0100 +++ b/scripts/getan-report Tue Jan 22 15:35:28 2019 +0100 @@ -14,16 +14,23 @@ import argparse from getan.template import render +from getan.backend import DEFAULT_DATABASE def main(): usage='getan-report [options]' - parser = argparse.ArgumentParser(prog='getan', usage=usage) + parser = argparse.ArgumentParser(prog='getan', usage=usage, + description="You can find more information at https://pypi.org/project/getan/") - parser.add_argument('-d', '--database', dest='database',metavar="DATABASE", - help='metavar="DATABASE') + parser.add_argument('-d', '--database', dest='database',metavar="DATABASE_FILE", + help='databasefile (default: ~/.getan/%(default)s)]', + default=DEFAULT_DATABASE) parser.add_argument('-t', '--template', dest='template', - metavar='TEMPLATE', help='name of getan template') + metavar='TEMPLATE', + help="""name of getan template (wochenbericht, + zeiterfassung, zeiterfassung2), + external templates must be stored in + ~/.getan/templates/ to be able to call them.""") parser.add_argument('-u', '--user', dest='user', help='name of user') parser.add_argument('-p', '--project', dest='project', help='key of output project')