diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-10-13 17:52:31 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-10-13 17:52:31 +0100 |
commit | 5f14737bf6a7e415ec70388d547ff526f285e96d (patch) | |
tree | 597f70855c3354108fd19e5f572821a8ddb80b0b | |
parent | 80b63fc9200a3ff660c20efc4f29e848053a7f23 (diff) |
handling BadZipFile exception when opening corrupt xlsx file
-rw-r--r-- | datamaps/main.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/datamaps/main.py b/datamaps/main.py index c58de94..a36b468 100644 --- a/datamaps/main.py +++ b/datamaps/main.py @@ -19,6 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import logging from functools import partial +from zipfile import BadZipFile import click from click import version_option @@ -108,6 +109,9 @@ def templates(to_master): click.style("Incorrect headers in datamap. {}.".format(e.args[0]), bold=True, reverse=True, fg="cyan")) except RemoveFileWithNoSheetRequiredByDatamap: logging.info("Import complete.") + except RuntimeError as e: + logger.critical(e) + logger.critical("Not completing import process.") else: click.secho("Not implemented yet. Try --to-master/-m flag") @@ -133,7 +137,7 @@ def master(master): blank = input_dir / blank_fn datamap = input_dir / datamap_fn -# click.secho(f"Exporting master {master} to templates based on {blank}...") +# click.secho(f"EXPORTING master {master} to templates based on {blank}...") be_logger.info(f"Exporting master {master} to templates based on {blank}...") try: |