-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support concurrent audio metadata extraction
- Loading branch information
Showing
9 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import shutil | ||
import tempfile | ||
from pathlib import Path | ||
|
||
|
||
__all__ = [ | ||
"TempFile", | ||
] | ||
|
||
|
||
class TempFile: | ||
def __init__(self, original_path): | ||
# type: (str|Path) -> None | ||
self.original_path = Path(original_path) | ||
self.temp_dir = None | ||
|
||
def __enter__(self): | ||
# type: () -> Path | ||
self.temp_dir = Path(tempfile.mkdtemp()) | ||
temp_filename = self.temp_dir / self.original_path.name | ||
shutil.copy2(self.original_path, temp_filename) | ||
return temp_filename | ||
|
||
def __exit__(self, exc_type, exc_value, traceback): | ||
shutil.rmtree(self.temp_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
import iscc_sdk as idk | ||
|
||
|
||
def test_tempfile(jpg_file): | ||
with idk.TempFile(jpg_file) as tf: | ||
assert tf.exists() | ||
assert not tf.exists() |