Skip to content

Commit

Permalink
Merge pull request #382 from MSeifert04/helperfunc_use_argument_inste…
Browse files Browse the repository at this point in the history
…ad_of_global

Use local scope variables in the helper function in FileCollection._dict_from_fits_header
  • Loading branch information
mwcraig committed Aug 1, 2016
2 parents 7a4fa05 + 70d001f commit 616cf8e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ccdproc/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 616cf8e

Please sign in to comment.