Improve variable names and code style

This commit is contained in:
Thomas Robitaille
2019-11-12 14:29:20 +00:00
parent 0a437bc9d6
commit fa1cca1fee
2 changed files with 13 additions and 14 deletions

View File

@@ -1190,32 +1190,31 @@ class Sphinx:
``typ`` is a type of processing; ``'read'`` or ``'write'``.
"""
if typ == 'read':
attrname = 'parallel_read_safe'
message_none = __("the %s extension does not declare if it is safe "
"for parallel reading, assuming it isn't - please "
"ask the extension author to check and make it "
"explicit")
message_false = "the %s extension is not safe for parallel reading"
message_not_declared = __("the %s extension does not declare if it "
"is safe for parallel reading, assuming "
"it isn't - please ask the extension author "
"to check and make it explicit")
message_not_safe = __("the %s extension is not safe for parallel reading")
elif typ == 'write':
attrname = 'parallel_write_safe'
message_none = __("the %s extension does not declare if it is safe "
"for parallel writing, assuming it isn't - please "
"ask the extension author to check and make it "
"explicit")
message_false = "the %s extension is not safe for parallel writing"
message_not_declared = __("the %s extension does not declare if it "
"is safe for parallel writing, assuming "
"it isn't - please ask the extension author "
"to check and make it explicit")
message_not_safe = __("the %s extension is not safe for parallel writing")
else:
raise ValueError('parallel type %s is not supported' % typ)
for ext in self.extensions.values():
allowed = getattr(ext, attrname, None)
if allowed is None:
logger.warning(message_none, ext.name)
logger.warning(message_not_declared, ext.name)
logger.warning(__('doing serial %s'), typ)
return False
elif not allowed:
logger.warning(message_false, ext.name)
logger.warning(message_not_safe, ext.name)
logger.warning(__('doing serial %s'), typ)
return False

View File

@@ -105,7 +105,7 @@ def test_add_is_parallel_allowed(app, status, warning):
app.setup_extension('read_serial')
assert app.is_parallel_allowed('read') is False
assert ("the read_serial extension is not safe for parallel reading") in warning.getvalue()
assert "the read_serial extension is not safe for parallel reading" in warning.getvalue()
warning.truncate(0) # reset warnings
assert app.is_parallel_allowed('write') is True
assert warning.getvalue() == ''