summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2021-11-28 20:22:40 -0500
committerJeff Forcier <jeff@bitprophet.org>2021-11-28 20:24:18 -0500
commit81f49ed4fcd46685002d4dd8b299a6c8fb3b2367 (patch)
treeed502dd9dc6547c560741221703f4f4c6eb3ad31
parentbbdf8040f5c24afd6e26089a3eb7da5f774f8e8b (diff)
Blacken code for #992
-rw-r--r--paramiko/py3compat.py8
-rw-r--r--paramiko/sftp_attr.py8
-rw-r--r--tests/__init__.py9
-rw-r--r--tests/test_sftp.py12
4 files changed, 22 insertions, 15 deletions
diff --git a/paramiko/py3compat.py b/paramiko/py3compat.py
index 0330abac..d6d136fb 100644
--- a/paramiko/py3compat.py
+++ b/paramiko/py3compat.py
@@ -45,7 +45,7 @@ if PY2:
def bytestring(s): # NOQA
if isinstance(s, unicode): # NOQA
- return s.encode('utf-8')
+ return s.encode("utf-8")
return s
byte_ord = ord # NOQA
@@ -111,7 +111,9 @@ if PY2:
def strftime(format, t):
"""Same as time.strftime but returns unicode."""
_, encoding = locale.getlocale(locale.LC_TIME)
- return time.strftime(format, t).decode(encoding or 'ascii')
+ return time.strftime(format, t).decode(encoding or "ascii")
+
+
else:
import collections
import struct
@@ -180,4 +182,4 @@ else:
MAXSIZE = sys.maxsize # NOQA
- strftime = time.strftime # NOQA
+ strftime = time.strftime # NOQA
diff --git a/paramiko/sftp_attr.py b/paramiko/sftp_attr.py
index 1ad16349..8b1c17bd 100644
--- a/paramiko/sftp_attr.py
+++ b/paramiko/sftp_attr.py
@@ -208,10 +208,10 @@ class SFTPAttributes(object):
time_tuple = time.localtime(self.st_mtime)
if abs(time.time() - self.st_mtime) > 15552000:
# (15552000 = 6 months)
- datestr = strftime('%d %b %Y', time_tuple)
+ datestr = strftime("%d %b %Y", time_tuple)
else:
- datestr = strftime('%d %b %H:%M', time_tuple)
- filename = getattr(self, 'filename', '?')
+ datestr = strftime("%d %b %H:%M", time_tuple)
+ filename = getattr(self, "filename", "?")
# not all servers support uid/gid
uid = self.st_uid
@@ -237,7 +237,7 @@ class SFTPAttributes(object):
)
def asbytes(self):
- return self._as_text().encode('utf-8')
+ return self._as_text().encode("utf-8")
if PY2:
__unicode__ = _as_text
diff --git a/tests/__init__.py b/tests/__init__.py
index 7ded9f18..db5ade5a 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -12,9 +12,14 @@ from pytest import skip
# with names that include accented characters.
_non_ascii_locales = [
# East Asian locales
- "ja_JP", "ko_KR", "zh_CN", "zh_TW",
+ "ja_JP",
+ "ko_KR",
+ "zh_CN",
+ "zh_TW",
# European locales with non-latin alphabets
- "el_GR", "ru_RU", "uk_UA",
+ "el_GR",
+ "ru_RU",
+ "uk_UA",
]
# Also include UTF-8 versions of these locales
_non_ascii_locales.extend([name + ".utf8" for name in _non_ascii_locales])
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 1d6048bb..6134d070 100644
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -274,12 +274,12 @@ class TestSFTP(object):
@requireNonAsciiLocale()
def test_listdir_in_locale(self, sftp):
"""Test listdir under a locale that uses non-ascii text."""
- sftp.open(sftp.FOLDER + '/canard.txt', 'w').close()
+ sftp.open(sftp.FOLDER + "/canard.txt", "w").close()
try:
folder_contents = sftp.listdir(sftp.FOLDER)
- self.assertEqual(['canard.txt'], folder_contents)
+ self.assertEqual(["canard.txt"], folder_contents)
finally:
- sftp.remove(sftp.FOLDER + '/canard.txt')
+ sftp.remove(sftp.FOLDER + "/canard.txt")
def test_setstat(self, sftp):
"""
@@ -792,12 +792,12 @@ class TestSFTP(object):
finally:
sftp.remove("%s/nonutf8data" % sftp.FOLDER)
- @requireNonAsciiLocale('LC_TIME')
+ @requireNonAsciiLocale("LC_TIME")
def test_sftp_attributes_locale_time(self, sftp):
"""Test SFTPAttributes under a locale with non-ascii time strings."""
some_stat = os.stat(sftp.FOLDER)
- sftp_attributes = SFTPAttributes.from_stat(some_stat, u('a_directory'))
- self.assertTrue(b'a_directory' in sftp_attributes.asbytes())
+ sftp_attributes = SFTPAttributes.from_stat(some_stat, u("a_directory"))
+ self.assertTrue(b"a_directory" in sftp_attributes.asbytes())
def test_sftp_attributes_empty_str(self, sftp):
sftp_attributes = SFTPAttributes()