Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project.get(): Accept non-list args (strings) #2853

Merged
merged 3 commits into from
Jul 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
project.get(): Accept non-list args
previously project.get() required its argument to be a list, or it
would bail with a warning. This created lots of awkward code like:
`get_app().project.get(["layers"])`. Now, if a non-empty, non-list
arg is passed in, it simply promotes it to a list and continues,
making `get_app().project.get("layers")` valid and equivalent.
  • Loading branch information
ferdnyc committed Jul 8, 2019
commit 88e41c57b583af2463b8a86ba6b7c4e706ef1a5a
5 changes: 2 additions & 3 deletions src/classes/project_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ def get(self, key):
""" Get copied value of a given key in data store """

# Verify key is valid type
if not isinstance(key, list):
log.warning("get() key must be a list. key: {}".format(key))
return None
if not key:
log.warning("Cannot get empty key.")
return None
if not isinstance(key, list):
key = [key]

# Get reference to internal data structure
obj = self._data
Expand Down