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
|
ERROR_HTTP_5XX = 5
|
||||||
|
|
||||||
|
|
||||||
EXIT_STATUS_LABELS = dict(
|
EXIT_STATUS_LABELS = {
|
||||||
(value, key)
|
value: key
|
||||||
for key, value in ExitStatus.__dict__.items()
|
for key, value in ExitStatus.__dict__.items()
|
||||||
if key.isupper()
|
if key.isupper()
|
||||||
)
|
}
|
||||||
|
@ -166,7 +166,7 @@ def get_requests_kwargs(args, base_headers=None):
|
|||||||
'cert': cert,
|
'cert': cert,
|
||||||
'timeout': args.timeout,
|
'timeout': args.timeout,
|
||||||
'auth': args.auth,
|
'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,
|
'files': args.files,
|
||||||
'allow_redirects': args.follow,
|
'allow_redirects': args.follow,
|
||||||
'params': args.params,
|
'params': args.params,
|
||||||
|
@ -112,11 +112,11 @@ SSL_VERSION_ARG_MAPPING = {
|
|||||||
'tls1.1': 'PROTOCOL_TLSv1_1',
|
'tls1.1': 'PROTOCOL_TLSv1_1',
|
||||||
'tls1.2': 'PROTOCOL_TLSv1_2',
|
'tls1.2': 'PROTOCOL_TLSv1_2',
|
||||||
}
|
}
|
||||||
SSL_VERSION_ARG_MAPPING = dict(
|
SSL_VERSION_ARG_MAPPING = {
|
||||||
(cli_arg, getattr(ssl, ssl_constant))
|
cli_arg: getattr(ssl, ssl_constant)
|
||||||
for cli_arg, ssl_constant in SSL_VERSION_ARG_MAPPING.items()
|
for cli_arg, ssl_constant in SSL_VERSION_ARG_MAPPING.items()
|
||||||
if hasattr(ssl, ssl_constant)
|
if hasattr(ssl, ssl_constant)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
|
||||||
class HTTPieArgumentParser(ArgumentParser):
|
class HTTPieArgumentParser(ArgumentParser):
|
||||||
|
@ -39,8 +39,7 @@ class PluginManager(object):
|
|||||||
return [plugin for plugin in self if issubclass(plugin, AuthPlugin)]
|
return [plugin for plugin in self if issubclass(plugin, AuthPlugin)]
|
||||||
|
|
||||||
def get_auth_plugin_mapping(self):
|
def get_auth_plugin_mapping(self):
|
||||||
return dict((plugin.auth_type, plugin)
|
return {plugin.auth_type: plugin for plugin in self.get_auth_plugins()}
|
||||||
for plugin in self.get_auth_plugins())
|
|
||||||
|
|
||||||
def get_auth_plugin(self, auth_type):
|
def get_auth_plugin(self, auth_type):
|
||||||
return self.get_auth_plugin_mapping()[auth_type]
|
return self.get_auth_plugin_mapping()[auth_type]
|
||||||
|
@ -136,10 +136,10 @@ class Session(BaseConfigDict):
|
|||||||
stored_attrs = ['value', 'path', 'secure', 'expires']
|
stored_attrs = ['value', 'path', 'secure', 'expires']
|
||||||
self['cookies'] = {}
|
self['cookies'] = {}
|
||||||
for cookie in jar:
|
for cookie in jar:
|
||||||
self['cookies'][cookie.name] = dict(
|
self['cookies'][cookie.name] = {
|
||||||
(attname, getattr(cookie, attname))
|
attname: getattr(cookie, attname)
|
||||||
for attname in stored_attrs
|
for attname in stored_attrs
|
||||||
)
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auth(self):
|
def auth(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user