diff options
author | bjv <brandon.vanvaerenbergh@noaa.gov> | 2015-12-23 12:12:57 -0800 |
---|---|---|
committer | bjv <brandon.vanvaerenbergh@noaa.gov> | 2015-12-23 12:12:57 -0800 |
commit | c718484c54a4a2ecf6bfc6986f4d90a6befbf126 (patch) | |
tree | 4aa83f5525df37b7362f94e73909356cbb838c7e /dateutil/zoneinfo | |
parent | e3e19b35a1edb85fe512aa2004d65440f22cb302 (diff) | |
download | dateutil-c718484c54a4a2ecf6bfc6986f4d90a6befbf126.tar.gz |
refactored exception suite into function
exception suite is now less prone to indentation typos
Diffstat (limited to 'dateutil/zoneinfo')
-rw-r--r-- | dateutil/zoneinfo/rebuild.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/dateutil/zoneinfo/rebuild.py b/dateutil/zoneinfo/rebuild.py index ff3bea0..a66c1d9 100644 --- a/dateutil/zoneinfo/rebuild.py +++ b/dateutil/zoneinfo/rebuild.py @@ -25,11 +25,7 @@ def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None): try: check_call(["zic", "-d", zonedir] + filepaths) except OSError as e: - if e.errno == 2: - logging.error( - "Could not find zic. Perhaps you need to install " - "libc-bin or some other package that provides it, " - "or it's not in your PATH?") + _print_on_nosuchfile(e) raise # write metadata file with open(os.path.join(zonedir, METADATA_FN), 'w') as f: @@ -41,3 +37,15 @@ def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None): tf.add(entrypath, entry) finally: shutil.rmtree(tmpdir) + +def _print_on_nosuchfile(e): + """Print helpful troubleshooting message + + e is an exception raised by subprocess.check_call() + + """ + if e.errno == 2: + logging.error( + "Could not find zic. Perhaps you need to install " + "libc-bin or some other package that provides it, " + "or it's not in your PATH?") |