Implement get_file

This commit is contained in:
Pradyun S. Gedam 2017-04-08 11:03:46 +05:30
parent 891a10c6de
commit 558edd6882
2 changed files with 13 additions and 0 deletions

View File

@ -180,6 +180,11 @@ class ConfigurationCommand(Command):
return ERROR
file = self.configuration.get_file()
if file is None:
logger.error(
"Could not determine appropriate file."
)
return ERROR
try:
subprocess.check_call([options.editor, file])

View File

@ -89,6 +89,14 @@ class Configuration(object):
if not self.isolated:
self._load_environment_vars()
def get_file(self):
"""Returns the file with highest priority in configuration
"""
try:
return self._get_parser_to_modify()[0]
except IndexError:
return None
def items(self):
"""Returns key-value pairs like dict.items() representing the loaded
configuration