Skip to content

Commit 7d7c32b

Browse files
authored
Ran black on everything (#200)
1 parent 731f99e commit 7d7c32b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3560
-4133
lines changed

fs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Python filesystem abstraction layer.
22
"""
33

4-
__import__('pkg_resources').declare_namespace(__name__)
4+
__import__("pkg_resources").declare_namespace(__name__)
55

66
from ._version import __version__
77
from .enums import ResourceType, Seek
88
from .opener import open_fs
99
from ._fscompat import fsencode, fsdecode
1010

11-
__all__ = ['__version__', 'ResourceType', 'Seek', 'open_fs']
11+
__all__ = ["__version__", "ResourceType", "Seek", "open_fs"]

fs/_bulk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Copier(object):
7777
def __init__(self, num_workers=4):
7878
# type: (int) -> None
7979
if num_workers < 0:
80-
raise ValueError('num_workers must be >= 0')
80+
raise ValueError("num_workers must be >= 0")
8181
self.num_workers = num_workers
8282
self.queue = None # type: Optional[Queue[_Task]]
8383
self.workers = [] # type: List[_Worker]

fs/_fscompat.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
try:
1111
from os import fspath
1212
except ImportError:
13+
1314
def fspath(path):
1415
"""Return the path representation of a path-like object.
1516
@@ -27,14 +28,17 @@ def fspath(path):
2728
try:
2829
path_repr = path_type.__fspath__(path)
2930
except AttributeError:
30-
if hasattr(path_type, '__fspath__'):
31+
if hasattr(path_type, "__fspath__"):
3132
raise
3233
else:
33-
raise TypeError("expected string type or os.PathLike object, "
34-
"not " + path_type.__name__)
34+
raise TypeError(
35+
"expected string type or os.PathLike object, "
36+
"not " + path_type.__name__
37+
)
3538
if isinstance(path_repr, (six.text_type, bytes)):
3639
return path_repr
3740
else:
38-
raise TypeError("expected {}.__fspath__() to return string type "
39-
"not {}".format(path_type.__name__,
40-
type(path_repr).__name__))
41+
raise TypeError(
42+
"expected {}.__fspath__() to return string type "
43+
"not {}".format(path_type.__name__, type(path_repr).__name__)
44+
)

fs/_ftp_parse.py

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@
3434
(.*?)
3535
$
3636
""",
37-
re.VERBOSE
37+
re.VERBOSE,
3838
)
3939

4040

4141
def get_decoders():
42-
decoders = [
43-
(re_linux, decode_linux),
44-
]
42+
decoders = [(re_linux, decode_linux)]
4543
return decoders
4644

4745

@@ -65,12 +63,12 @@ def parse_line(line):
6563

6664

6765
def _parse_time(t):
68-
t = ' '.join(token.strip() for token in t.lower().split(' '))
66+
t = " ".join(token.strip() for token in t.lower().split(" "))
6967
try:
7068
try:
71-
_t = time.strptime(t, '%b %d %Y')
69+
_t = time.strptime(t, "%b %d %Y")
7270
except ValueError:
73-
_t = time.strptime(t, '%b %d %H:%M')
71+
_t = time.strptime(t, "%b %d %H:%M")
7472
except ValueError:
7573
# Unknown time format
7674
return None
@@ -80,56 +78,41 @@ def _parse_time(t):
8078
day = _t.tm_mday
8179
hour = _t.tm_hour
8280
minutes = _t.tm_min
83-
dt = datetime.datetime(
84-
year, month, day,
85-
hour, minutes,
86-
tzinfo=UTC
87-
)
81+
dt = datetime.datetime(year, month, day, hour, minutes, tzinfo=UTC)
8882

8983
epoch_time = (dt - epoch_dt).total_seconds()
9084
return epoch_time
9185

9286

9387
def decode_linux(line, match):
9488
perms, links, uid, gid, size, mtime, name = match.groups()
95-
is_link = perms.startswith('l')
96-
is_dir = perms.startswith('d') or is_link
89+
is_link = perms.startswith("l")
90+
is_dir = perms.startswith("d") or is_link
9791
if is_link:
98-
name, _, _link_name = name.partition('->')
92+
name, _, _link_name = name.partition("->")
9993
name = name.strip()
10094
_link_name = _link_name.strip()
10195
permissions = Permissions.parse(perms[1:])
10296

10397
mtime_epoch = _parse_time(mtime)
10498

105-
name = unicodedata.normalize('NFC', name)
99+
name = unicodedata.normalize("NFC", name)
106100

107101
raw_info = {
108-
"basic": {
109-
"name": name,
110-
"is_dir": is_dir
111-
},
102+
"basic": {"name": name, "is_dir": is_dir},
112103
"details": {
113104
"size": int(size),
114-
"type": int(
115-
ResourceType.directory
116-
if is_dir else
117-
ResourceType.file
118-
)
119-
},
120-
"access": {
121-
"permissions": permissions.dump()
105+
"type": int(ResourceType.directory if is_dir else ResourceType.file),
122106
},
123-
"ftp": {
124-
"ls": line
125-
}
107+
"access": {"permissions": permissions.dump()},
108+
"ftp": {"ls": line},
126109
}
127-
access = raw_info['access']
128-
details = raw_info['details']
110+
access = raw_info["access"]
111+
details = raw_info["details"]
129112
if mtime_epoch is not None:
130-
details['modified'] = mtime_epoch
113+
details["modified"] = mtime_epoch
131114

132-
access['user'] = uid
133-
access['group'] = gid
115+
access["user"] = uid
116+
access["group"] = gid
134117

135118
return raw_info

fs/_repr.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ def make_repr(class_name, *args, **kwargs):
3131
3232
"""
3333
arguments = [repr(arg) for arg in args]
34-
arguments.extend([
35-
"{}={!r}".format(name, value)
36-
for name, (value, default) in sorted(kwargs.items())
37-
if value != default
38-
])
39-
return "{}({})".format(class_name, ', '.join(arguments))
34+
arguments.extend(
35+
[
36+
"{}={!r}".format(name, value)
37+
for name, (value, default) in sorted(kwargs.items())
38+
if value != default
39+
]
40+
)
41+
return "{}({})".format(class_name, ", ".join(arguments))

fs/_typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
from typing import overload # type: ignore
1212

1313
if _PY.major == 3 and _PY.minor == 5 and _PY.micro in (0, 1):
14+
1415
def overload(func): # pragma: no cover
1516
return func
1617

18+
1719
try:
1820
from typing import Text
1921
except ImportError: # pragma: no cover

fs/appfs.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
from typing import Optional, Text
2020

2121

22-
__all__ = ['UserDataFS',
23-
'UserConfigFS',
24-
'SiteDataFS',
25-
'SiteConfigFS',
26-
'UserCacheFS',
27-
'UserLogFS']
22+
__all__ = [
23+
"UserDataFS",
24+
"UserConfigFS",
25+
"SiteDataFS",
26+
"SiteConfigFS",
27+
"UserCacheFS",
28+
"UserLogFS",
29+
]
2830

2931

3032
class _AppFS(OSFS):
@@ -36,19 +38,19 @@ class _AppFS(OSFS):
3638
# (subclass override will raise errors until then)
3739
app_dir = None # type: Text
3840

39-
def __init__(self,
40-
appname, # type: Text
41-
author=None, # type: Optional[Text]
42-
version=None, # type: Optional[Text]
43-
roaming=False, # type: bool
44-
create=True # type: bool
45-
):
41+
def __init__(
42+
self,
43+
appname, # type: Text
44+
author=None, # type: Optional[Text]
45+
version=None, # type: Optional[Text]
46+
roaming=False, # type: bool
47+
create=True, # type: bool
48+
):
4649
# type: (...) -> None
4750
self.app_dirs = AppDirs(appname, author, version, roaming)
4851
self._create = create
4952
super(_AppFS, self).__init__(
50-
getattr(self.app_dirs, self.app_dir),
51-
create=create
53+
getattr(self.app_dirs, self.app_dir), create=create
5254
)
5355

5456
def __repr__(self):
@@ -59,14 +61,13 @@ def __repr__(self):
5961
author=(self.app_dirs.appauthor, None),
6062
version=(self.app_dirs.version, None),
6163
roaming=(self.app_dirs.roaming, False),
62-
create=(self._create, True)
64+
create=(self._create, True),
6365
)
6466

6567
def __str__(self):
6668
# type: () -> Text
6769
return "<{} '{}'>".format(
68-
self.__class__.__name__.lower(),
69-
self.app_dirs.appname
70+
self.__class__.__name__.lower(), self.app_dirs.appname
7071
)
7172

7273

@@ -88,7 +89,7 @@ class UserDataFS(_AppFS):
8889
8990
"""
9091

91-
app_dir = 'user_data_dir'
92+
app_dir = "user_data_dir"
9293

9394

9495
class UserConfigFS(_AppFS):
@@ -109,7 +110,7 @@ class UserConfigFS(_AppFS):
109110
110111
"""
111112

112-
app_dir = 'user_config_dir'
113+
app_dir = "user_config_dir"
113114

114115

115116
class UserCacheFS(_AppFS):
@@ -130,7 +131,7 @@ class UserCacheFS(_AppFS):
130131
131132
"""
132133

133-
app_dir = 'user_cache_dir'
134+
app_dir = "user_cache_dir"
134135

135136

136137
class SiteDataFS(_AppFS):
@@ -151,7 +152,7 @@ class SiteDataFS(_AppFS):
151152
152153
"""
153154

154-
app_dir = 'site_data_dir'
155+
app_dir = "site_data_dir"
155156

156157

157158
class SiteConfigFS(_AppFS):
@@ -172,7 +173,7 @@ class SiteConfigFS(_AppFS):
172173
173174
"""
174175

175-
app_dir = 'site_config_dir'
176+
app_dir = "site_config_dir"
176177

177178

178179
class UserLogFS(_AppFS):
@@ -193,4 +194,4 @@ class UserLogFS(_AppFS):
193194
194195
"""
195196

196-
app_dir = 'user_log_dir'
197+
app_dir = "user_log_dir"

0 commit comments

Comments
 (0)