Skip to content

Commit 15d43d5

Browse files
committed
Format code
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent acb85c0 commit 15d43d5

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/extractcode/archive.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,34 @@ def should_extract(location, kinds, ignore_pattern=()):
112112
Return True if this location should be extracted based on the provided kinds
113113
"""
114114
location = os.path.abspath(os.path.expanduser(location))
115-
ignore_pattern = {extension : 'User ignore: Supplied by --ignore' for extension in ignore_pattern}
115+
ignore_pattern = {extension : 'User ignore: Supplied by --ignore'
116+
for extension in ignore_pattern}
116117
should_ignore = is_ignored(location, ignore_pattern)
117118
extractor = get_extractor(location, kinds=kinds)
118119

119120
if TRACE_DEEP:
120-
logger.debug(f' should_extract: extractor: {extractor}, should_ignore: {should_ignore}')
121+
logger.debug(
122+
f' should_extract: extractor: {extractor}, '
123+
f'should_ignore: {should_ignore}'
124+
)
121125

122126
if extractor and not should_ignore:
123127
return True
124128

125129

126130
def get_extractor(location, kinds=all_kinds):
127131
"""
128-
Return an extraction callable that can extract the file at location or
129-
an None if no extract function is found.
132+
Return an extraction callable that can extract the file at ``location`` or
133+
None if no extraction callable function is found.
134+
Limit the search for an extractor to the ``kinds`` list of archive kinds.
135+
See extractcode.all_kinds for details.
136+
137+
An extraction callable should accept these arguments:
138+
- location of the file to extract
139+
- target_dir where to extract
140+
It should extract files from the `location` in the `target_dir` directory.
141+
It must return a list of warning messages if any or an empty list.
142+
It must raise Exceptions on errors.
130143
"""
131144
assert location
132145
location = os.path.abspath(os.path.expanduser(location))

src/extractcode/libarchive2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ def extract(location, target_dir, skip_symlinks=True):
185185
logger.debug('skipping: {}'.format(entry))
186186

187187
if entry.issym and not skip_symlinks:
188-
raise NotImplemented('extraction of symlinks with libarchive is not yet implemented.')
188+
raise NotImplemented(
189+
'extraction of symlinks with libarchive is not yet implemented.')
189190
continue
190191

191192
if TRACE:

src/extractcode/sevenzip.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def extract(location, target_dir, arch_type='*', file_by_file=on_mac, skip_symli
230230
location=abs_location,
231231
target_dir=abs_target_dir,
232232
arch_type=arch_type,
233-
skip_symlinks=skip_symlinks)
233+
skip_symlinks=skip_symlinks,
234+
)
234235

235236

236237
def extract_all_files_at_once(location, target_dir, arch_type='*', skip_symlinks=True):

0 commit comments

Comments
 (0)