Skip to content

Commit f1c2620

Browse files
László Vaskóe3krisztian
authored andcommitted
processing: process_files -> process_file
It can only process one file, so it is a more meaningful name
1 parent 0b831c9 commit f1c2620

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

tests/test_cleanup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010

1111
from unblob.models import File, Handler, Regex, ValidChunk
12-
from unblob.processing import ExtractionConfig, process_files
12+
from unblob.processing import ExtractionConfig, process_file
1313
from unblob.testing import check_result
1414

1515
_ZIP_CONTENT = b"good file"
@@ -54,7 +54,7 @@ def test_remove_extracted_chunks(input_dir: Path, output_dir: Path):
5454
entropy_depth=0,
5555
)
5656

57-
all_reports = process_files(config, input_dir)
57+
all_reports = process_file(config, input_dir)
5858
assert list(output_dir.glob("**/*.zip")) == []
5959
check_result(all_reports)
6060

@@ -66,7 +66,7 @@ def test_keep_all_problematic_chunks(input_dir: Path, output_dir: Path):
6666
entropy_depth=0,
6767
)
6868

69-
all_reports = process_files(config, input_dir)
69+
all_reports = process_file(config, input_dir)
7070
# damaged zip file should not be removed
7171
assert all_reports.errors != [], "Unexpectedly no errors found!"
7272
assert list(output_dir.glob("**/*.zip"))
@@ -79,7 +79,7 @@ def test_keep_all_unknown_chunks(input_dir: Path, output_dir: Path):
7979
entropy_depth=0,
8080
)
8181

82-
all_reports = process_files(config, input_dir)
82+
all_reports = process_file(config, input_dir)
8383
assert list(output_dir.glob("**/*.unknown"))
8484
check_result(all_reports)
8585

@@ -100,6 +100,6 @@ def test_keep_chunks_with_null_extractor(input_dir: Path, output_dir: Path):
100100
entropy_depth=0,
101101
handlers=(_HandlerWithNullExtractor,),
102102
)
103-
all_reports = process_files(config, input_dir)
103+
all_reports = process_file(config, input_dir)
104104
assert list(output_dir.glob("**/*.null"))
105105
check_result(all_reports)

tests/test_cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ def test_archive_success(
174174
/ "regular"
175175
/ "__input__/"
176176
)
177-
process_files_mock = mock.MagicMock()
177+
process_file_mock = mock.MagicMock()
178178
logger_config_mock = mock.MagicMock()
179179
new_params = params + ["--extract-dir", str(tmp_path), str(in_path)]
180180
with mock.patch.object(
181-
unblob.cli, "process_files", process_files_mock
181+
unblob.cli, "process_file", process_file_mock
182182
), mock.patch.object(unblob.cli, "configure_logger", logger_config_mock):
183183
result = runner.invoke(unblob.cli.cli, new_params)
184184
assert result.exit_code == 0
@@ -192,7 +192,7 @@ def test_archive_success(
192192
process_num=expected_process_num,
193193
handlers=BUILTIN_HANDLERS,
194194
)
195-
process_files_mock.assert_called_once_with(config, in_path)
195+
process_file_mock.assert_called_once_with(config, in_path)
196196
logger_config_mock.assert_called_once_with(expected_verbosity, tmp_path)
197197

198198

@@ -218,13 +218,13 @@ def test_keep_extracted_chunks(
218218
)
219219
params = args + ["--extract-dir", str(tmp_path), str(in_path)]
220220

221-
process_files_mock = mock.MagicMock()
222-
with mock.patch.object(unblob.cli, "process_files", process_files_mock):
221+
process_file_mock = mock.MagicMock()
222+
with mock.patch.object(unblob.cli, "process_file", process_file_mock):
223223
result = runner.invoke(unblob.cli.cli, params)
224224

225225
assert result.exit_code == 0
226-
process_files_mock.assert_called_once()
226+
process_file_mock.assert_called_once()
227227
assert (
228-
process_files_mock.call_args.args[0].keep_extracted_chunks
228+
process_file_mock.call_args.args[0].keep_extracted_chunks
229229
== keep_extracted_chunks
230230
), fail_message

tests/test_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from unblob import handlers
1717
from unblob.models import Handler
18-
from unblob.processing import ExtractionConfig, process_files
18+
from unblob.processing import ExtractionConfig, process_file
1919
from unblob.testing import (
2020
check_output_is_the_same,
2121
check_result,
@@ -32,7 +32,7 @@
3232
def test_all_handlers(
3333
input_dir: Path, output_dir: Path, extraction_config: ExtractionConfig
3434
):
35-
all_reports = process_files(extraction_config, input_dir)
35+
all_reports = process_file(extraction_config, input_dir)
3636

3737
check_output_is_the_same(output_dir, extraction_config.extract_root)
3838
check_result(all_reports)

unblob/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
DEFAULT_PROCESS_NUM,
2020
DEFAULT_SKIP_MAGIC,
2121
ExtractionConfig,
22-
process_files,
22+
process_file,
2323
)
2424

2525
logger = get_logger()
@@ -192,7 +192,7 @@ def cli(
192192
)
193193

194194
logger.info("Start processing file", file=file)
195-
all_reports = process_files(config, file)
195+
all_reports = process_file(config, file)
196196
return all_reports
197197

198198

unblob/processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ExtractionConfig:
6767

6868

6969
@terminate_gracefully
70-
def process_files(config: ExtractionConfig, path: Path) -> ProcessResult:
70+
def process_file(config: ExtractionConfig, path: Path) -> ProcessResult:
7171
task = Task(
7272
path=path,
7373
depth=0,

unblob/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def extraction_config(tmp_path: Path):
4646
keep_extracted_chunks=True,
4747
)
4848

49-
# Warmup lru_cache before ``process_files`` forks, so child
49+
# Warmup lru_cache before ``process_file`` forks, so child
5050
# processes can reuse the prebuilt databases without overhead
5151
build_hyperscan_database(config.handlers)
5252

0 commit comments

Comments
 (0)