Skip to content

Commit c722d08

Browse files
committed
Fix extractusm mode when given a directory as input
1 parent bf3174f commit c722d08

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.2] - 2021-09-09
8+
### Fixed
9+
- Fixed bug in command-line extractusm mode where it fails to find usms when given a directory.
10+
711
## [0.2.1] - 2021-09-01
812
### Added
913
- This changelog

wannacri/wannacri.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def probe_usm():
160160
"path": usmfile.replace(args.input, ""),
161161
"version": wannacri.__version__,
162162
"os": f"{platform.system()} {platform.release()}",
163-
"is_local_ffprobe": False if ffprobe_path is None else True,
163+
"is_local_ffprobe": ffprobe_path is not None,
164164
},
165165
)
166166

@@ -320,23 +320,23 @@ def main():
320320
OP_DICT[args.operation]()
321321

322322

323-
def find_usm(path: str) -> List[str]:
323+
def find_usm(directory: str) -> List[str]:
324324
"""Walks a path to find USMs."""
325-
if os.path.isfile(path):
326-
with open(path, "rb") as test:
325+
if os.path.isfile(directory):
326+
with open(directory, "rb") as test:
327327
if not is_usm(test.read(4)):
328328
raise ValueError("Not a usm file.")
329329

330-
return [path]
330+
return [directory]
331331

332332
print("Finding USM files... ", end="", flush=True)
333333
usmfiles = []
334-
for path, _, files in os.walk(path):
334+
for path, _, files in os.walk(directory):
335335
for f in files:
336-
path = os.path.join(path, f)
337-
with open(path, "rb") as test:
336+
filepath = os.path.join(path, f)
337+
with open(filepath, "rb") as test:
338338
if is_usm(test.read(4)):
339-
usmfiles.append(path)
339+
usmfiles.append(filepath)
340340

341341
print(f"Found {len(usmfiles)}")
342342
return usmfiles

0 commit comments

Comments
 (0)