summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2017-09-09 11:54:04 +0200
committerMathieu Bridon <bochecha@daitauha.fr>2017-09-19 09:33:18 +0200
commitf40ae33b52197241880d7e6399bfd0e28c4ee468 (patch)
treed0986557c906067ef1d46f3fc38dc94756c125b7
parent4813c828b77233b83442662353c7ad0498f408b2 (diff)
downloadbuildstream-f40ae33b52197241880d7e6399bfd0e28c4ee468.tar.gz
Simplify a bit of code
There's no need to set a default value, then ignore a KeyError when we can directly use dict.get().
-rw-r--r--buildstream/_frontend/main.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index 87d89afb4..84e2850b1 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -71,7 +71,6 @@ def complete_target(ctx, args, incomplete):
# Now parse the project.conf just to find the element path,
# this is unfortunately a bit heavy.
project_file = os.path.join(base_directory, 'project.conf')
- element_directory = None
try:
project = _yaml.load(project_file)
except LoadError:
@@ -80,10 +79,7 @@ def complete_target(ctx, args, incomplete):
return []
# The project is not required to have an element-path
- try:
- element_directory = project['element-path']
- except KeyError:
- pass
+ element_directory = project.get('element-path')
# If a project was loaded, use it's element-path to
# adjust our completion's base directory