Skip to content

Commit 5108203

Browse files
gurukamathSamWilsn
authored andcommitted
delete only select files
1 parent 114c063 commit 5108203

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/ethereum_spec_tools/evm_tools/t8n/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import argparse
6+
import fnmatch
67
import json
78
import os
89
from functools import partial
@@ -251,10 +252,25 @@ def run_blockchain_test(self) -> None:
251252

252253
def run(self) -> int:
253254
"""Run the transition and provide the relevant outputs"""
254-
# Clean out files from the output directory
255+
# Clear files that may have been created in a previous
256+
# run of the t8n tool.
257+
# Define the specific files and pattern to delete
258+
files_to_delete = [
259+
self.options.output_result,
260+
self.options.output_alloc,
261+
self.options.output_body,
262+
]
263+
pattern_to_delete = "trace-*.jsonl"
264+
265+
# Iterate through the directory
255266
for file in os.listdir(self.options.output_basedir):
256-
if file.endswith(".json") or file.endswith(".jsonl"):
257-
os.remove(os.path.join(self.options.output_basedir, file))
267+
file_path = os.path.join(self.options.output_basedir, file)
268+
269+
# Check if the file matches the specific names or the pattern
270+
if file in files_to_delete or fnmatch.fnmatch(
271+
file, pattern_to_delete
272+
):
273+
os.remove(file_path)
258274

259275
try:
260276
if self.options.state_test:

0 commit comments

Comments
 (0)