Skip to content

Commit

Permalink
Support for Expanded IPM parameter file extraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
adelosa committed Jun 10, 2024
1 parent b936518 commit 6fcdc1c
Show file tree
Hide file tree
Showing 8 changed files with 503 additions and 169 deletions.
49 changes: 37 additions & 12 deletions cardutil/cli/mci_ipm_param_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,49 @@ def cli_run(**kwargs):


def cli_parser():
parser = argparse.ArgumentParser(prog='mci_ipm_param_to_csv', description='Mastercard IPM parameter file to CSV')
parser.add_argument('in_filename', help='IPM Parameter file to process')
parser.add_argument('table_id', help='Parameter table to extract')
parser.add_argument('-o', '--out-filename')
parser.add_argument('--in-encoding')
parser.add_argument('--out-encoding')
parser.add_argument('--debug', action='store_true')
parser.add_argument('--no1014blocking', action='store_true')
parser.add_argument('--config-file', help='File containing cardutil configuration - JSON format')
parser = argparse.ArgumentParser(
prog="mci_ipm_param_to_csv", description="Mastercard IPM parameter file to CSV"
)
parser.add_argument("in_filename", help="IPM Parameter file to process")
parser.add_argument("table_id", help="Parameter table to extract")
parser.add_argument("-o", "--out-filename")
parser.add_argument("--in-encoding")
parser.add_argument("--out-encoding")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--no1014blocking", action="store_true")
parser.add_argument("--expanded", action="store_true")
parser.add_argument(
"--config-file", help="File containing cardutil configuration - JSON format"
)
add_version(parser)

return parser


def mci_ipm_param_to_csv(in_param, out_csv, table_id, config=None, in_encoding=None, no1014blocking=False, **_):
def mci_ipm_param_to_csv(
in_param,
out_csv,
table_id,
config=None,
in_encoding=None,
no1014blocking=False,
expanded=False,
**_
):
blocked = not no1014blocking
vbs_in = mciipm.IpmParamReader(in_param, table_id, param_config=config, blocked=blocked, encoding=in_encoding)
csv_writer = csv.DictWriter(out_csv, fieldnames=config[table_id].keys(), extrasaction="ignore", lineterminator="\n")
vbs_in = mciipm.IpmParamReader(
in_param,
table_id,
param_config=config,
blocked=blocked,
encoding=in_encoding,
expanded=expanded,
)
fieldnames = ["table_id", "effective_timestamp", "active_inactive_code"]
fieldnames.extend(config[table_id].keys())
csv_writer = csv.DictWriter(
out_csv, fieldnames=fieldnames, extrasaction="ignore", lineterminator="\n"
)
csv_writer.writeheader()
csv_writer.writerows(vbs_in)

Expand Down
Loading

0 comments on commit 6fcdc1c

Please sign in to comment.