Skip to content

Commit

Permalink
Add int_conversion
Browse files Browse the repository at this point in the history
 - Implement int check in dict_load()
  • Loading branch information
astrochun committed Apr 2, 2021
1 parent 512c075 commit 61c851c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions requiam/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ def figshare_group(group, root_stem, production=True):
return grouper_group


def int_conversion(string):
try:
value = int(string)
except ValueError:
value = string
return value


def dict_load(config_file, vargs=None):
"""
Purpose:
Expand Down Expand Up @@ -105,13 +113,13 @@ def dict_load(config_file, vargs=None):
if vargs[p] is not None:
if p in config_dict['global']:
# If input argument is set, override global settings
config_dict['global'][p] = vargs[p]
config_dict['global'][p] = int_conversion(vargs[p])
else:
if p in config_dict['google']:
config_dict['google'][p] = vargs[p]
config_dict['google'][p] = int_conversion(vargs[p])
else:
# Add to extras dictionary
config_dict['extras'][p] = vargs[p]
config_dict['extras'][p] = int_conversion(vargs[p])
else:
if (p not in config_dict['global']) and \
(p not in config_dict['google']):
Expand Down

0 comments on commit 61c851c

Please sign in to comment.