Skip to content

Commit

Permalink
simplified a bit exception for list append
Browse files Browse the repository at this point in the history
  • Loading branch information
darthbear committed Nov 15, 2018
1 parent 3ce6821 commit 3bfe203
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions pyhocon/config_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,13 @@ def get_list(self, key, default=UndefinedKey):
if isinstance(value, list):
return value
elif isinstance(value, ConfigTree):
try:
lst = []
sorted_tree = sorted(value.items())
for k, v in sorted_tree:
if re.match('^[1-9][0-9]*$|0', k):
lst.append(v)
else:
raise ValueError
return lst
except ValueError:
raise ConfigException(
u"{key} does not translate to a list".format(key=key))
lst = []
for k, v in sorted(value.items(), key=lambda kv: kv[0]):
if re.match('^[1-9][0-9]*$|0', k):
lst.append(v)
else:
raise ConfigException(u"{key} does not translate to a list".format(key=key))
return lst
elif value is None:
return None
else:
Expand Down

0 comments on commit 3bfe203

Please sign in to comment.