# HG changeset patch # User Tom Gottfried # Date 1578565954 -3600 # Node ID a59622c069368d4aa979f1caa5115de4dde9c302 # Parent d5acadeef0f859649892cb1c355839638fbd1204 Fix generating reports if no week given unix_week() cannot handle week being None but does so for year. It just assumes the current year in this case, although this only duplicates the initialisation of year with c_year in this context. week being None gives TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' load_entries() handles the case with no week given, thus call it anyhow. This fix makes it possible to invoke scripts/getan-report with a year given but no week and seeing the expected result (data for a whole year) instead of a traceback. diff -r d5acadeef0f8 -r a59622c06936 getan/template.py --- a/getan/template.py Wed Jan 08 09:22:23 2020 +0100 +++ b/getan/template.py Thu Jan 09 11:32:34 2020 +0100 @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # (c) 2014 by Björn Ricks +# 2017, 2018, 2020 Intevation GmbH # # This is Free Software licensed under the terms of GPLv3 or later. # For details see LICENSE coming with the source of 'getan'. @@ -108,10 +109,11 @@ project = backend.load_project(project) projects = [project] - if year is not None or week is not None: + if week is not None: u_week = "%02d" % unix_week(week, year) - for project in projects: - project.load_entries(year, u_week) + + for project in projects: + project.load_entries(year, u_week) if not empty_projects: projects = [project for project in projects if project.entries]