Skip to content

Commit 9f3cb10

Browse files
committed
Format and clarify code and variable names
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 8eca070 commit 9f3cb10

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/extractcode/extract.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@
9797
ExtractEvent = namedtuple('ExtractEvent', 'source target done warnings errors')
9898

9999

100-
def extract(location, kinds=extractcode.default_kinds, recurse=False, replace_originals=False, ignore_pattern=()):
100+
def extract(
101+
location,
102+
kinds=extractcode.default_kinds,
103+
recurse=False,
104+
replace_originals=False,
105+
ignore_pattern=(),
106+
):
101107
"""
102108
Walk and extract any archives found at `location` (either a file or
103109
directory). Extract only archives of a kind listed in the `kinds` kind tuple.
@@ -143,7 +149,12 @@ def extract(location, kinds=extractcode.default_kinds, recurse=False, replace_or
143149
fileutils.delete(target)
144150

145151

146-
def extract_files(location, kinds=extractcode.default_kinds, recurse=False, ignore_pattern=()):
152+
def extract_files(
153+
location,
154+
kinds=extractcode.default_kinds,
155+
recurse=False,
156+
ignore_pattern=(),
157+
):
147158
"""
148159
Extract the files found at `location`.
149160
@@ -170,6 +181,7 @@ def extract_files(location, kinds=extractcode.default_kinds, recurse=False, igno
170181
dirs.remove(d)
171182
if TRACE:
172183
logger.debug('extract:walk: not recurse: removed dirs:' + repr(drs.symmetric_difference(set(dirs))))
184+
173185
for f in files:
174186
loc = join(top, f)
175187
if not recurse and extractcode.is_extraction_path(loc):
@@ -195,13 +207,23 @@ def extract_files(location, kinds=extractcode.default_kinds, recurse=False, igno
195207
if recurse:
196208
if TRACE:
197209
logger.debug('extract:walk: recursing on target: %(target)r' % locals())
198-
for xevent in extract(location=target, kinds=kinds, recurse=recurse, ignore_pattern=ignore_pattern):
210+
for xevent in extract(
211+
location=target,
212+
kinds=kinds,
213+
recurse=recurse,
214+
ignore_pattern=ignore_pattern,
215+
):
199216
if TRACE:
200217
logger.debug('extract:walk:recurse:extraction event: %(xevent)r' % locals())
201218
yield xevent
202219

203220

204-
def extract_file(location, target, kinds=extractcode.default_kinds, verbose=False):
221+
def extract_file(
222+
location,
223+
target,
224+
kinds=extractcode.default_kinds,
225+
verbose=False,
226+
):
205227
"""
206228
Extract a single archive at `location` in the `target` directory if it is
207229
of a kind supported in the `kinds` kind tuple.
@@ -211,7 +233,7 @@ def extract_file(location, target, kinds=extractcode.default_kinds, verbose=Fals
211233
extractor = archive.get_extractor(location, kinds)
212234
if TRACE:
213235
emodule = getattr(extractor, '__module__', '')
214-
ename =getattr(extractor, '__name__', '')
236+
ename = getattr(extractor, '__name__', '')
215237
logger.debug(
216238
'extract_file: extractor: for: {location} with kinds: {kinds}: {emodule}.{ename}'
217239
.format(**locals()))

0 commit comments

Comments
 (0)