forked from extern/httpie-cli
Start using dict comprehensions
This commit is contained in:
parent
ec899d70b7
commit
7f5fd130c5
@ -25,8 +25,8 @@ class ExitStatus:
|
||||
ERROR_HTTP_5XX = 5
|
||||
|
||||
|
||||
EXIT_STATUS_LABELS = dict(
|
||||
(value, key)
|
||||
EXIT_STATUS_LABELS = {
|
||||
value: key
|
||||
for key, value in ExitStatus.__dict__.items()
|
||||
if key.isupper()
|
||||
)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ def get_requests_kwargs(args, base_headers=None):
|
||||
'cert': cert,
|
||||
'timeout': args.timeout,
|
||||
'auth': args.auth,
|
||||
'proxies': dict((p.key, p.value) for p in args.proxy),
|
||||
'proxies': {p.key: p.value for p in args.proxy},
|
||||
'files': args.files,
|
||||
'allow_redirects': args.follow,
|
||||
'params': args.params,
|
||||
|
@ -112,11 +112,11 @@ SSL_VERSION_ARG_MAPPING = {
|
||||
'tls1.1': 'PROTOCOL_TLSv1_1',
|
||||
'tls1.2': 'PROTOCOL_TLSv1_2',
|
||||
}
|
||||
SSL_VERSION_ARG_MAPPING = dict(
|
||||
(cli_arg, getattr(ssl, ssl_constant))
|
||||
SSL_VERSION_ARG_MAPPING = {
|
||||
cli_arg: getattr(ssl, ssl_constant)
|
||||
for cli_arg, ssl_constant in SSL_VERSION_ARG_MAPPING.items()
|
||||
if hasattr(ssl, ssl_constant)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class HTTPieArgumentParser(ArgumentParser):
|
||||
|
@ -39,8 +39,7 @@ class PluginManager(object):
|
||||
return [plugin for plugin in self if issubclass(plugin, AuthPlugin)]
|
||||
|
||||
def get_auth_plugin_mapping(self):
|
||||
return dict((plugin.auth_type, plugin)
|
||||
for plugin in self.get_auth_plugins())
|
||||
return {plugin.auth_type: plugin for plugin in self.get_auth_plugins()}
|
||||
|
||||
def get_auth_plugin(self, auth_type):
|
||||
return self.get_auth_plugin_mapping()[auth_type]
|
||||
|
@ -136,10 +136,10 @@ class Session(BaseConfigDict):
|
||||
stored_attrs = ['value', 'path', 'secure', 'expires']
|
||||
self['cookies'] = {}
|
||||
for cookie in jar:
|
||||
self['cookies'][cookie.name] = dict(
|
||||
(attname, getattr(cookie, attname))
|
||||
self['cookies'][cookie.name] = {
|
||||
attname: getattr(cookie, attname)
|
||||
for attname in stored_attrs
|
||||
)
|
||||
}
|
||||
|
||||
@property
|
||||
def auth(self):
|
||||
|
Loading…
Reference in New Issue
Block a user