mirror of
https://github.com/certbot/certbot.git
synced 2026-08-04 12:21:51 +02:00
Converted dict comprehensions to use literals. (#8342)
This commit is contained in:
+1
-1
@@ -448,7 +448,7 @@ class Client(ClientBase):
|
|||||||
heapq.heapify(waiting)
|
heapq.heapify(waiting)
|
||||||
# mapping between original Authorization Resource and the most
|
# mapping between original Authorization Resource and the most
|
||||||
# recently updated one
|
# recently updated one
|
||||||
updated = dict((authzr, authzr) for authzr in authzrs)
|
updated = {authzr: authzr for authzr in authzrs}
|
||||||
|
|
||||||
while waiting:
|
while waiting:
|
||||||
# find the smallest Retry-After, and sleep if necessary
|
# find the smallest Retry-After, and sleep if necessary
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class Directory(jose.JSONDeSerializable):
|
|||||||
external_account_required = jose.Field('externalAccountRequired', omitempty=True)
|
external_account_required = jose.Field('externalAccountRequired', omitempty=True)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
kwargs = dict((self._internal_name(k), v) for k, v in kwargs.items())
|
kwargs = {self._internal_name(k): v for k, v in kwargs.items()}
|
||||||
super(Directory.Meta, self).__init__(**kwargs)
|
super(Directory.Meta, self).__init__(**kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -465,7 +465,7 @@ class ChallengeBody(ResourceBody):
|
|||||||
omitempty=True, default=None)
|
omitempty=True, default=None)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
kwargs = dict((self._internal_name(k), v) for k, v in kwargs.items())
|
kwargs = {self._internal_name(k): v for k, v in kwargs.items()}
|
||||||
super(ChallengeBody, self).__init__(**kwargs)
|
super(ChallengeBody, self).__init__(**kwargs)
|
||||||
|
|
||||||
def encode(self, name):
|
def encode(self, name):
|
||||||
|
|||||||
+1
-1
@@ -4,4 +4,4 @@ import six
|
|||||||
|
|
||||||
def map_keys(dikt, func):
|
def map_keys(dikt, func):
|
||||||
"""Map dictionary keys."""
|
"""Map dictionary keys."""
|
||||||
return dict((func(key), value) for key, value in six.iteritems(dikt))
|
return {func(key): value for key, value in six.iteritems(dikt)}
|
||||||
|
|||||||
@@ -192,8 +192,8 @@ class HelpfulArgumentParser(object):
|
|||||||
if self.detect_defaults:
|
if self.detect_defaults:
|
||||||
return parsed_args
|
return parsed_args
|
||||||
|
|
||||||
self.defaults = dict((key, copy.deepcopy(self.parser.get_default(key)))
|
self.defaults = {key: copy.deepcopy(self.parser.get_default(key))
|
||||||
for key in vars(parsed_args))
|
for key in vars(parsed_args)}
|
||||||
|
|
||||||
# Do any post-parsing homework here
|
# Do any post-parsing homework here
|
||||||
|
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ class PluginsRegistry(Mapping):
|
|||||||
|
|
||||||
def filter(self, pred):
|
def filter(self, pred):
|
||||||
"""Filter plugins based on predicate."""
|
"""Filter plugins based on predicate."""
|
||||||
return type(self)(dict((name, plugin_ep) for name, plugin_ep
|
return type(self)({name: plugin_ep for name, plugin_ep
|
||||||
in six.iteritems(self._plugins) if pred(plugin_ep)))
|
in six.iteritems(self._plugins) if pred(plugin_ep)})
|
||||||
|
|
||||||
def visible(self):
|
def visible(self):
|
||||||
"""Filter plugins based on visibility."""
|
"""Filter plugins based on visibility."""
|
||||||
|
|||||||
@@ -1126,7 +1126,7 @@ class RenewableCert(interfaces.RenewableCert):
|
|||||||
logger.debug("Writing full chain to %s.", target["fullchain"])
|
logger.debug("Writing full chain to %s.", target["fullchain"])
|
||||||
f.write(new_cert + new_chain)
|
f.write(new_cert + new_chain)
|
||||||
|
|
||||||
symlinks = dict((kind, self.configuration[kind]) for kind in ALL_FOUR)
|
symlinks = {kind: self.configuration[kind] for kind in ALL_FOUR}
|
||||||
# Update renewal config file
|
# Update renewal config file
|
||||||
self.configfile = update_configuration(
|
self.configfile = update_configuration(
|
||||||
self.lineagename, self.archive_dir, symlinks, cli_config)
|
self.lineagename, self.archive_dir, symlinks, cli_config)
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class BaseCertManagerTest(test_util.ConfigTestCase):
|
|||||||
"example.org": None,
|
"example.org": None,
|
||||||
"other.com": os.path.join(self.config.config_dir, "specialarchive")
|
"other.com": os.path.join(self.config.config_dir, "specialarchive")
|
||||||
}
|
}
|
||||||
self.config_files = dict((domain, self._set_up_config(domain, self.domains[domain]))
|
self.config_files = {domain: self._set_up_config(domain, self.domains[domain])
|
||||||
for domain in self.domains)
|
for domain in self.domains}
|
||||||
|
|
||||||
# We also create a file that isn't a renewal config in the same
|
# We also create a file that isn't a renewal config in the same
|
||||||
# location to test that logic that reads in all-and-only renewal
|
# location to test that logic that reads in all-and-only renewal
|
||||||
@@ -80,8 +80,8 @@ class UpdateLiveSymlinksTest(BaseCertManagerTest):
|
|||||||
archive_dir_path = custom_archive
|
archive_dir_path = custom_archive
|
||||||
else:
|
else:
|
||||||
archive_dir_path = os.path.join(self.config.default_archive_dir, domain)
|
archive_dir_path = os.path.join(self.config.default_archive_dir, domain)
|
||||||
archive_paths[domain] = dict((kind,
|
archive_paths[domain] = {kind:
|
||||||
os.path.join(archive_dir_path, kind + "1.pem")) for kind in ALL_FOUR)
|
os.path.join(archive_dir_path, kind + "1.pem") for kind in ALL_FOUR}
|
||||||
for kind in ALL_FOUR:
|
for kind in ALL_FOUR:
|
||||||
live_path = self.config_files[domain][kind]
|
live_path = self.config_files[domain][kind]
|
||||||
archive_path = archive_paths[domain][kind]
|
archive_path = archive_paths[domain][kind]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from certbot.compat import os
|
|||||||
|
|
||||||
def get_signals(signums):
|
def get_signals(signums):
|
||||||
"""Get the handlers for an iterable of signums."""
|
"""Get the handlers for an iterable of signums."""
|
||||||
return dict((s, signal.getsignal(s)) for s in signums)
|
return {s: signal.getsignal(s) for s in signums}
|
||||||
|
|
||||||
|
|
||||||
def set_signals(sig_handler_dict):
|
def set_signals(sig_handler_dict):
|
||||||
@@ -28,7 +28,7 @@ def signal_receiver(signums):
|
|||||||
"""Context manager to catch signals"""
|
"""Context manager to catch signals"""
|
||||||
signals = []
|
signals = []
|
||||||
prev_handlers = get_signals(signums) # type: Dict[int, Union[int, None, Callable]]
|
prev_handlers = get_signals(signums) # type: Dict[int, Union[int, None, Callable]]
|
||||||
set_signals(dict((s, lambda s, _: signals.append(s)) for s in signums))
|
set_signals({s: lambda s, _: signals.append(s) for s in signums})
|
||||||
yield signals
|
yield signals
|
||||||
set_signals(prev_handlers)
|
set_signals(prev_handlers)
|
||||||
|
|
||||||
|
|||||||
@@ -1492,7 +1492,7 @@ class UnregisterTest(unittest.TestCase):
|
|||||||
'account': mock.patch('certbot._internal.main.account'),
|
'account': mock.patch('certbot._internal.main.account'),
|
||||||
'client': mock.patch('certbot._internal.main.client'),
|
'client': mock.patch('certbot._internal.main.client'),
|
||||||
'get_utility': test_util.patch_get_utility()}
|
'get_utility': test_util.patch_get_utility()}
|
||||||
self.mocks = dict((k, v.start()) for k, v in self.patchers.items())
|
self.mocks = {k: v.start() for k, v in self.patchers.items()}
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for patch in self.patchers.values():
|
for patch in self.patchers.values():
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ def _prepare_environment():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if not os.name == 'nt':
|
if os.name != 'nt':
|
||||||
raise RuntimeError('This script must be run under Windows.')
|
raise RuntimeError('This script must be run under Windows.')
|
||||||
|
|
||||||
if ctypes.windll.shell32.IsUserAnAdmin() == 0:
|
if ctypes.windll.shell32.IsUserAnAdmin() == 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user