lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit df19a818d8e7091d1d3a2b8d9c31954a50665a23
parent 8ca7c73df5994a30f3b1070f8c000beef454849e
Author: rsiddharth <rsd@gnu.org>
Date:   Sat, 13 Jul 2019 18:47:08 -0400

lps_gen.py: Update template_read.

* lps_gen.py (template_read): Add exception handling for non-existent
  templates.
* tests/test_lps_gen.py (TestTemplates.test_read): Add non-existent
  template test.

Diffstat:
lps_gen.py | 8+++++++-
tests/test_lps_gen.py | 3+++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lps_gen.py b/lps_gen.py @@ -99,7 +99,13 @@ def template_read(name): p = 'lpschedule_generator' r = 'data/{}'.format(name) - return pkgr.resource_string(p, r).decode('utf-8') + t = None + try: + t = pkgr.resource_string(p, r).decode('utf-8') + except Exception as e: + print(e, file=sys.stderr) + + return t class LPiCal(object): diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py @@ -113,6 +113,9 @@ class TestTemplates(object): assert type(t) is str assert len(t) > 0 + t = template_read('nonexistent.jinja2') + assert t is None + class TestLPiCal(object): """