mirror of
https://github.com/httpie/cli.git
synced 2025-06-04 23:27:28 +02:00
Cleanup
This commit is contained in:
parent
45e8e4e4ea
commit
c946b3d34f
@ -19,8 +19,6 @@ from httpie.utils import repr_dict
|
|||||||
try:
|
try:
|
||||||
# noinspection PyPackageRequirements
|
# noinspection PyPackageRequirements
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
|
|
||||||
# <https://urllib3.readthedocs.io/en/latest/security.html>
|
# <https://urllib3.readthedocs.io/en/latest/security.html>
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
@ -128,10 +126,10 @@ def get_response(
|
|||||||
|
|
||||||
with max_headers(args.max_headers):
|
with max_headers(args.max_headers):
|
||||||
if not args.session and not args.session_read_only:
|
if not args.session and not args.session_read_only:
|
||||||
kwargs = make_requests_kwargs(args)
|
requests_kwargs = make_requests_kwargs(args)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
dump_request(kwargs)
|
dump_request(requests_kwargs)
|
||||||
response = requests_session.request(**kwargs)
|
response = requests_session.request(**requests_kwargs)
|
||||||
else:
|
else:
|
||||||
response = sessions.get_response(
|
response = sessions.get_response(
|
||||||
requests_session=requests_session,
|
requests_session=requests_session,
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
import pygments.lexer
|
import pygments.lexer
|
||||||
import pygments.token
|
|
||||||
import pygments.styles
|
|
||||||
import pygments.lexers
|
import pygments.lexers
|
||||||
import pygments.style
|
import pygments.style
|
||||||
|
import pygments.styles
|
||||||
|
import pygments.token
|
||||||
from pygments.formatters.terminal import TerminalFormatter
|
from pygments.formatters.terminal import TerminalFormatter
|
||||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||||
|
from pygments.lexer import Lexer
|
||||||
from pygments.lexers.special import TextLexer
|
from pygments.lexers.special import TextLexer
|
||||||
from pygments.lexers.text import HttpLexer as PygmentsHttpLexer
|
from pygments.lexers.text import HttpLexer as PygmentsHttpLexer
|
||||||
from pygments.util import ClassNotFound
|
from pygments.util import ClassNotFound
|
||||||
@ -26,7 +28,6 @@ if is_windows:
|
|||||||
# great and fruity seems to give the best result there.
|
# great and fruity seems to give the best result there.
|
||||||
DEFAULT_STYLE = 'fruity'
|
DEFAULT_STYLE = 'fruity'
|
||||||
|
|
||||||
|
|
||||||
AVAILABLE_STYLES = set(pygments.styles.get_all_styles())
|
AVAILABLE_STYLES = set(pygments.styles.get_all_styles())
|
||||||
AVAILABLE_STYLES.add(SOLARIZED_STYLE)
|
AVAILABLE_STYLES.add(SOLARIZED_STYLE)
|
||||||
AVAILABLE_STYLES.add(AUTO_STYLE)
|
AVAILABLE_STYLES.add(AUTO_STYLE)
|
||||||
@ -90,7 +91,7 @@ class ColorFormatter(FormatterPlugin):
|
|||||||
def get_lexer_for_body(
|
def get_lexer_for_body(
|
||||||
self, mime: str,
|
self, mime: str,
|
||||||
body: str
|
body: str
|
||||||
) -> Type[pygments.lexer.Lexer]:
|
) -> Optional[Type[Lexer]]:
|
||||||
return get_lexer(
|
return get_lexer(
|
||||||
mime=mime,
|
mime=mime,
|
||||||
explicit_json=self.explicit_json,
|
explicit_json=self.explicit_json,
|
||||||
@ -109,8 +110,7 @@ def get_lexer(
|
|||||||
mime: str,
|
mime: str,
|
||||||
explicit_json=False,
|
explicit_json=False,
|
||||||
body=''
|
body=''
|
||||||
) -> Type[pygments.lexer.Lexer]:
|
) -> Optional[Type[Lexer]]:
|
||||||
|
|
||||||
# Build candidate mime type and lexer names.
|
# Build candidate mime type and lexer names.
|
||||||
mime_types, lexer_names = [mime], []
|
mime_types, lexer_names = [mime], []
|
||||||
type_, subtype = mime.split('/', 1)
|
type_, subtype = mime.split('/', 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user