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

gsoc: Change the coafile warning/output #4370

Merged
merged 1 commit into from Jun 24, 2017
Jump to file or symbol
Failed to load files and symbols.
+20 −16
Diff settings

Always

Just for now

Change the coafile warning/output

  • Loading branch information...
Nosferatul committed Jun 17, 2017
commit 3e590f5e34f019103f98f0ea9b32c94d01e05472
@@ -13,6 +13,13 @@
from coalib.settings.Section import Section
from coalib.settings.SectionFilling import fill_settings
from coalib.settings.Setting import Setting, path
from string import Template
COAFILE_OUTPUT = Template('$type \'$file\' $found!\n'
'Here\'s what you can do:\n'
'* add `--save` to generate a config file with '
'your current options\n'
'* add `-I` to suppress any use of config files\n')
def merge_section_dicts(lower, higher):
@@ -59,18 +66,15 @@ def load_config_file(filename, log_printer, silent=False):
except FileNotFoundError:
if not silent:
if os.path.basename(filename) == Constants.default_coafile:
log_printer.warn('The default coafile {0!r} was not found. '
'You can generate a configuration file with '
'your current options by adding the `--save` '
'flag or suppress any use of config '
'files with `-I`.'
.format(Constants.default_coafile))
log_printer.warn(COAFILE_OUTPUT
.substitute(type='Default coafile',
file=Constants.default_coafile,
found='not found'))
else:
log_printer.err('The requested coafile {0!r} does not exist. '
'You can generate it with your current '
'options by adding the `--save` flag or '
'suppress any use of config files with `-I`.'
.format(filename))
log_printer.err(COAFILE_OUTPUT
.substitute(type='Requested coafile',
file=filename,
found='does not exist'))
sys.exit(2)
return {'default': Section('default')}
View
@@ -34,8 +34,8 @@ def test_nonexistent(self, debug=False):
coala.main, 'coala', '--non-interactive', '-c', 'nonex', 'test')
self.assertFalse(stdout)
self.assertRegex(
stderr,
".*\\[ERROR\\].*The requested coafile '.*' does not exist. .+\n")
stderr,
".*\\[ERROR\\].*Requested coafile '.*' does not exist")
self.assertNotEqual(retval, 0,
'coala must return nonzero when errors occured')
View
@@ -30,7 +30,7 @@ def test_nonexistent(self):
coala.main, 'coala', '--json', '-c', 'nonex', 'test')
test_text = '{\n "results": {}\n}\n'
self.assertEqual(stdout, test_text)
self.assertRegex(stderr, ".*requested coafile '.*' does not exist. .+")
self.assertRegex(stderr, ".*Requested coafile '.*' does not exist")
self.assertNotEqual(retval, 0,
'coala must return nonzero when errors occured')
@@ -116,8 +116,8 @@ def test_text_logs(self):
coala.main, 'coala', '--json', '-c', 'nonex')
test_text = '{\n "results": {}\n}\n'
self.assertRegex(
stderr,
".*\\[ERROR\\].*The requested coafile '.*' does not exist. .+\n")
stderr,
".*\\[ERROR\\].*Requested coafile '.*' does not exist")
self.assertEqual(stdout, test_text)
self.assertNotEqual(retval, 0,
'coala must return nonzero when errors occured')
ProTip! Use n and p to navigate between commits in a pull request.