aboutsummaryrefslogtreecommitdiffstats
path: root/datamaps/main.py
diff options
context:
space:
mode:
authorMR Lemon <matt@matthewlemon>2020-05-15 16:01:28 +0100
committerMR Lemon <matt@matthewlemon>2020-05-15 16:01:28 +0100
commita962f9411eab9f0e55620b8c686279edc254ccc0 (patch)
tree0d4a075f49dc173f975d0270b60d1716b61521d3 /datamaps/main.py
parentf83695aa8ac9e0c67f75bf02b84a554301029c1e (diff)
first two passing tests in implementing --datamap option in datamaps interface
Diffstat (limited to 'datamaps/main.py')
-rw-r--r--datamaps/main.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/datamaps/main.py b/datamaps/main.py
index f607e6e..407727d 100644
--- a/datamaps/main.py
+++ b/datamaps/main.py
@@ -32,7 +32,7 @@ from engine.exceptions import (DatamapFileEncodingError,
MissingCellKeyError, MissingLineError,
MissingSheetFieldError,
NoApplicableSheetsInTemplateFiles,
- RemoveFileWithNoSheetRequiredByDatamap)
+ RemoveFileWithNoSheetRequiredByDatamap, DatamapNotCSVException)
logging.basicConfig(level=logging.INFO, format="%(asctime)s: %(levelname)s - %(message)s", datefmt='%d-%b-%y %H:%M:%S')
logger = logging.getLogger(__name__)
@@ -103,10 +103,15 @@ def report():
default=False,
help="Create master.xlsx immediately",
)
-def templates(to_master):
+@click.option(
+ "--datamap",
+ "-d",
+ help="Path to datamap file",
+)
+def templates(to_master, datamap):
if to_master:
try:
- engine_cli.import_and_create_master(echo_funcs=output_funcs)
+ engine_cli.import_and_create_master(echo_funcs=output_funcs, datamap=datamap)
except MalFormedCSVHeaderException as e:
click.echo(
click.style("Incorrect headers in datamap. {}.".format(e.args[0]), bold=True, reverse=True, fg="cyan"))
@@ -128,6 +133,9 @@ def templates(to_master):
except DatamapFileEncodingError as e:
logger.critical(e)
sys.exit(1)
+ except DatamapNotCSVException as e:
+ logger.critical(e)
+ sys.exit(1)
else:
click.secho("Not implemented yet. Try --to-master/-m flag")