From 70d001fd1e4772228b4458f6d83329ce128b0141 Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 31 Jul 2016 15:51:16 +0200 Subject: [PATCH] Use local scope variables in the helper function in FileCollection._dict_from_fits_header. --- ccdproc/image_collection.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ccdproc/image_collection.py b/ccdproc/image_collection.py index d73cee1c..3db5c7c1 100644 --- a/ccdproc/image_collection.py +++ b/ccdproc/image_collection.py @@ -317,12 +317,13 @@ def _dict_from_fits_header(self, file_name, input_summary=None, """ from collections import OrderedDict - def _add_val_to_dict(key, value, tbl_dict, n_prev): + def _add_val_to_dict(key, value, tbl_dict, n_previous, missing_marker): + key = key.lower() try: - tbl_dict[key.lower()].append(value) + tbl_dict[key].append(value) except KeyError: - tbl_dict[key.lower()] = [missing_marker] * n_previous - tbl_dict[key.lower()].append(value) + tbl_dict[key] = [missing_marker] * n_previous + tbl_dict[key].append(value) if input_summary is None: summary = OrderedDict() @@ -359,12 +360,13 @@ def _add_val_to_dict(key, value, tbl_dict, n_prev): else: val = v - _add_val_to_dict(k, val, summary, n_previous) + _add_val_to_dict(k, val, summary, n_previous, missing_marker) for k, v in six.iteritems(multi_entry_keys): if v: joined = ','.join(v) - _add_val_to_dict(k, joined, summary, n_previous) + _add_val_to_dict(k, joined, summary, n_previous, + missing_marker) for missing in missing_in_this_file: summary[missing].append(missing_marker)