From 6239ae055fac6c0c9bec6b8a7e2a5dcc7c02d23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nut=CC=A6iu?= Date: Wed, 19 Apr 2017 15:53:29 +0300 Subject: [PATCH] Adding a new file for utility methods --- src/resources/__init__.py | 17 +++++++++++++++++ src/resources/utilities.py | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/resources/__init__.py create mode 100644 src/resources/utilities.py diff --git a/src/resources/__init__.py b/src/resources/__init__.py new file mode 100644 index 0000000..1987b55 --- /dev/null +++ b/src/resources/__init__.py @@ -0,0 +1,17 @@ +""" + Author: Denis Nutiu + This file is part of scoreboard-benchmark. + + scoreboard-benchmark is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + scoreboard-benchmark is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with scoreboard-benchmark . If not, see . +""" \ No newline at end of file diff --git a/src/resources/utilities.py b/src/resources/utilities.py new file mode 100644 index 0000000..59ab02d --- /dev/null +++ b/src/resources/utilities.py @@ -0,0 +1,27 @@ +""" + Author: Denis Nutiu + This file is part of scoreboard-benchmark. + + scoreboard-benchmark is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + scoreboard-benchmark is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with scoreboard-benchmark . If not, see . +""" + + +def to_zero_count(page_no): + try: + page_no = int(page_no) - 1 + if page_no < 0: + page_no = 0 + except (TypeError, ValueError): # page_no is not an int + page_no = 0 + return page_no