Prepend current directory when path is just filename

This commit is contained in:
Mihai Dinca 2018-08-23 16:14:36 +02:00 committed by rallytime
parent c7bae5e795
commit 6d691b290b
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -595,10 +595,19 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
)
)
def _logfile_callback(option, opt, value, parser, *args, **kwargs):
if not os.path.dirname(value):
# if the path is only a file name (no parent directory), assume current directory
value = os.path.join(os.path.curdir, value)
setattr(parser.values, self._logfile_config_setting_name_, value)
group.add_option(
'--log-file',
dest=self._logfile_config_setting_name_,
default=None,
action='callback',
type='string',
callback=_logfile_callback,
help='Log file path. Default: \'{0}\'.'.format(
self._default_logging_logfile_
)