forked from extern/httpie-cli
Minor clean-up (#1112)
* Remove Python 2 clean-up misses * Remove unused `Environment.devnull` setter * Simplifies `get_filename_max_length()`
This commit is contained in:
parent
2f8d7f77bd
commit
04d05a8abd
@ -119,10 +119,6 @@ class Environment:
|
||||
self._devnull = open(os.devnull, 'w+')
|
||||
return self._devnull
|
||||
|
||||
@devnull.setter
|
||||
def devnull(self, value):
|
||||
self._devnull = value
|
||||
|
||||
def log_error(self, msg, level='error'):
|
||||
assert level in ['error', 'warning']
|
||||
self._orig_stderr.write(f'\n{self.program_name}: {level}: {msg}\n\n')
|
||||
|
@ -2,7 +2,6 @@
|
||||
Download mode implementation.
|
||||
|
||||
"""
|
||||
import errno
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
@ -150,16 +149,8 @@ def trim_filename(filename: str, max_len: int) -> str:
|
||||
|
||||
def get_filename_max_length(directory: str) -> int:
|
||||
max_len = 255
|
||||
try:
|
||||
pathconf = os.pathconf
|
||||
except AttributeError:
|
||||
pass # non-posix
|
||||
else:
|
||||
try:
|
||||
max_len = pathconf(directory, 'PC_NAME_MAX')
|
||||
except OSError as e:
|
||||
if e.errno != errno.EINVAL:
|
||||
raise
|
||||
if hasattr(os, 'pathconf') and 'PC_NAME_MAX' in os.pathconf_names:
|
||||
max_len = os.pathconf(directory, 'PC_NAME_MAX')
|
||||
return max_len
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ def write_message(
|
||||
}
|
||||
try:
|
||||
if env.is_windows and 'colors' in args.prettify:
|
||||
write_stream_with_colors_win_py3(**write_stream_kwargs)
|
||||
write_stream_with_colors_win(**write_stream_kwargs)
|
||||
else:
|
||||
write_stream(**write_stream_kwargs)
|
||||
except OSError as e:
|
||||
@ -69,7 +69,7 @@ def write_stream(
|
||||
outfile.flush()
|
||||
|
||||
|
||||
def write_stream_with_colors_win_py3(
|
||||
def write_stream_with_colors_win(
|
||||
stream: 'BaseStream',
|
||||
outfile: TextIO,
|
||||
flush: bool
|
||||
|
@ -189,7 +189,7 @@ class TestSession(SessionTestBase):
|
||||
httpbin.url + '/get', env=self.env())
|
||||
assert HTTP_OK in r2
|
||||
|
||||
# FIXME: Authorization *sometimes* is not present on Python3
|
||||
# FIXME: Authorization *sometimes* is not present
|
||||
assert (r2.json['headers']['Authorization']
|
||||
== HTTPBasicAuth.make_header('test', UNICODE))
|
||||
# httpbin doesn't interpret utf8 headers
|
||||
|
Loading…
Reference in New Issue
Block a user