时间追踪器和报告器
zeitig的Python项目详细描述
时间追踪器。
其基本思想是将所有情况变化存储为事件流,并创建 作为这些数据的集合进行报告。
用法
Usage: z [OPTIONS] [GROUP] COMMAND [ARGS]... Options: --help Show this message and exit. Commands: add Apply tags and notes. break Change to or start the `break` situation. remove Remove tags and flush notes. report Create a report of your events. work Change to or start the `work` situation.
示例会话
您可以添加一个时间戳,如示例中所示,它是为您的时区解析的。 您可以缩短命令,因此缩短跟踪 运行项目只是z w和z b。
> export ZEITIG_STORE=/tmp/zeitig; mkdir $ZEITIG_STORE > z foobar work -t foo "2018-04-01 08:00:00" > z break "2018-04-01 12:00:00" > z w "2018-04-01 13:00:00" > z b "2018-04-01 17:30:00" > z Actual time: 2018-05-04 23:09:01 Actual group: foobar of foobar Last situation in foobar: Break started at 2018-04-01 17:30:00 since 797.65 hours Store used: /tmp/zeitig/olli Last event: groups/foobar/source/2018-04-01T15:30:00+00:00 > z report Working times for foobar until Friday 04 May 2018 Week: 13 2018-04-01 08:00:00 - 12:00:00 - 4.00 - foo 2018-04-01 13:00:00 - 17:30:00 - 4.50 Total hours: 8.50
内部构件
您可以在当前工作中的某个位置创建一个.zeitig目录 用作存储的目录路径。其他默认值是~/.config/zeitig 和~/.local/share/zeitig。
为每个用户创建一个单独的目录,其中包含组和 事件来源:
.zeitig/ | +- <user> | +- last ---+ | | +- groups | | | v | +- <group> | | | +- source | | | | | +- <event UTC timestamp> | | | +- templates | | | | | +- <jinja template> | | | +- template_defaults.toml | | | +- template_syntax.toml | +- templates | | | +- <jinja template> | +- template_defaults.toml | +- template_syntax.toml
事件存储为简单的toml文件。
报告
事件完全公开到报告模板。你可以确定 过滤器和聚合器以修改事件流。
模板由jinja2呈现。您可以通过 特殊的template_syntax.toml文件。
示例乳胶模板可能如下所示:
\documentclass{article}\usepackage[a4paper, total={6in, 8in}]{geometry}\usepackage{longtable,array,titling,booktabs}\setlength{\parindent}{0pt}\setlength{\parskip}{\baselineskip}\title{\vspace{-13em}Timesheet\vspace{0em}}\author{\vspace{-10em}}\date{\vspace{-5em}}% sans serif font \renewcommand{\familydefault}{\sfdefault}\begin{document}\maketitle\thispagestyle{empty}% no page footer \vspace{-5em}\begin{longtable}{ >{\raggedleft\arraybackslash}r >{\raggedright\arraybackslash}l}\textbf{Client}: & We do something special\\\textbf{Contractor}: & Oliver Berger\\\textbf{Project number}: & 12-345-6789-0\\\end{longtable}\begin{longtable}{ >{\raggedright\arraybackslash}l >{\raggedright\arraybackslash}l >{\raggedleft\arraybackslash}r >{\raggedright\arraybackslash}l} Start & End & Hours & Description\\\BLOCK{for event in events.pipeline( report.source, events.filter_no_breaks, events.Summary.aggregate, events.DatetimeChange.aggregate )-}\BLOCK{if py.isinstance(event, events.DatetimeChange) and event.is_new_week}\midrule\BLOCK{endif-}\BLOCK{if py.isinstance(event, events.Work)}\VAR{event.local_start.to_datetime_string()}&\VAR{event.local_end.to_time_string()}&\VAR{'{0:.2f}'.format(event.period.total_hours())}&\BLOCK{if event.tags}\VAR{', '.join(event.tags)}\BLOCK{endif-}\\\BLOCK{endif-}\BLOCK{if py.isinstance(event, events.Summary)}\midrule\multicolumn{2}{l}{\textbf{Total hours}}&\textbf{\VAR{'{0:.2f}'.format(event.works.total_hours())}}&\\\BLOCK{endif-}\BLOCK{-endfor-}\end{longtable}\vspace{5em}\begin{longtable}{ >{\centering\arraybackslash}p{3.5cm} l >{\centering\arraybackslash}p{5.5cm}}\cline{1-1}\cline{3-3} Date && Signature of client\\\end{longtable}\end{document}
jinja语法
组jinja模板语法将合并到用户语法中:
[jinja_env] [jinja_env.latex] # define a latex jinja env block_start_string = "\\BLOCK{" block_end_string = "}" variable_start_string = "\\VAR{" variable_end_string = "}" comment_start_string = "\\#{" comment_end_string = "}" line_statement_prefix = "%%" line_comment_prefix = "%#" trim_blocks = true autoescape = false [templates] # map a template name to a jinja env latex_template = "latex"
Jinja默认值
您还可以为组定义模板默认值,该组将被合并到 用户模板默认值。