From 4ee35ebb1545afe24c6c3a6c8e78b3a5d0d481a2 Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Tue, 26 May 2015 22:36:07 -0600 Subject: [PATCH] Remove lines of code unreached in tests. Instead of catching and logging processing exceptions, we just let the exception rise, which accomplishes the same thing. --- rasterio/rio/calc.py | 18 ++++++++---------- tests/test_rio_calc.py | 1 - 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/rasterio/rio/calc.py b/rasterio/rio/calc.py index 43a2d574..9a8c4bb9 100644 --- a/rasterio/rio/calc.py +++ b/rasterio/rio/calc.py @@ -18,11 +18,9 @@ from rasterio.rio.cli import ( def get_bands(inputs, d, i=None): """Get a rasterio.Band object from calc's inputs""" path = inputs[d] if d in dict(inputs) else inputs[int(d)-1][1] - if i: - return rasterio.band(rasterio.open(path), i) - else: - src = rasterio.open(path) - return [rasterio.band(src, i) for i in src.indexes] + src = rasterio.open(path) + return (rasterio.band(src, i) if i else + [rasterio.band(src, i) for i in src.indexes]) def read_array(ix, subix=None, dtype=None): @@ -141,8 +139,8 @@ def calc(ctx, command, files, output, name, dtype, masked): click.echo(' ' + ' ' * err.offset + "^") click.echo(err) raise click.Abort() - except Exception as err: - t, v, tb = sys.exc_info() - for line in traceback.format_exception_only(t, v): - click.echo(line, nl=False) - raise click.Abort() + #except Exception as err: + # t, v, tb = sys.exc_info() + # for line in traceback.format_exception_only(t, v): + # click.echo(line, nl=False) + # raise click.Abort() diff --git a/tests/test_rio_calc.py b/tests/test_rio_calc.py index 772e360a..40f0bb4b 100644 --- a/tests/test_rio_calc.py +++ b/tests/test_rio_calc.py @@ -129,7 +129,6 @@ def test_fillnodata(tmpdir): outfile], catch_exceptions=False) assert result.exit_code == 0 - # import subprocess; subprocess.call(['open', outfile]) with rasterio.open(outfile) as src: assert src.count == 3 assert src.meta['dtype'] == 'uint8'