Skip to content

Commit

Permalink
Make config lookups case insensitive
Browse files Browse the repository at this point in the history
The product names in config can be spelled in various and confusing
ways. Make the lookups not care about case.

Ideally this should use `casefold`, but that is only available since
Python 3.3. However the product names will almost certainly be ASCII
only.

Fixes: NEXUS-252
  • Loading branch information
lubomir committed Sep 18, 2019
1 parent cef62b1 commit a4de243
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rcm_nexus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_password(self):
return self.password

def get_profile_id(self, product, is_ga):
profiles = self.profile_map.get(product)
profiles = self.profile_map.get(product.upper())
if profiles is None:
raise Exception( "No staging profiles found for: '%s' in environment: %s" % (product, self.name) )

Expand All @@ -65,7 +65,9 @@ def get_profile_id(self, product, is_ga):
return profile_id

def get_promote_profile_id(self, product, is_ga):
return self.profile_map[product][GA_PROMOTE_PROFILE if is_ga else EA_PROMOTE_PROFILE]
return self.profile_map[product.upper()][
GA_PROMOTE_PROFILE if is_ga else EA_PROMOTE_PROFILE
]

def __str__(self):
return """RCMNexusConfig [
Expand Down Expand Up @@ -126,7 +128,7 @@ def _read_config(path):
with open(path) as f:
parser.readfp(f)
for product in parser.sections():
result[product] = dict(parser.items(product))
result[product.upper()] = dict(parser.items(product))
return result


Expand Down

0 comments on commit a4de243

Please sign in to comment.