Skip to content

Commit 351a1c8

Browse files
committed
fixed command line overwrite options
1 parent ab03842 commit 351a1c8

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

openmc_data_downloader/openmc_data_downloader

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@ if __name__ == '__main__':
6666
)
6767

6868
parser.add_argument(
69-
'-o', '--overwrite',
70-
type=bool, default=True,
71-
help='Should exiting files be overwritten'
69+
'--overwrite',
70+
action='store_true',
71+
help='Exiting files will be overwritten'
7272
)
7373

74+
parser.add_argument(
75+
'--no-overwrite',
76+
action='store_false',
77+
help='Exiting files will not be overwritten'
78+
)
79+
80+
parser.set_defaults(overwrite=False)
7481
args = parser.parse_args()
7582

7683
just_in_time_library_generator(

tests/test_command_line_usage.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
import os
7+
import time
78
import unittest
89
from pathlib import Path
910

@@ -146,3 +147,22 @@ def test_sab_download_with_endf(self):
146147
assert Path("ENDFB-7.1-NNDC_c_Be_in_BeO.h5").is_file()
147148
assert Path("materials.xml").is_file()
148149
assert len(list(Path(".").glob("*.h5"))) == 5
150+
151+
def test_download_single_file_with_overwrite_speed_up(self):
152+
"""Checks that downloading with overwrite to False is quicker"""
153+
154+
current_time = time.time()
155+
os.system(
156+
"openmc_data_downloader -l ENDFB-7.1-NNDC TENDL-2019 -e Be --overwrite"
157+
)
158+
time_after_download = time.time()
159+
time_to_download = time_after_download - current_time
160+
161+
current_time = time.time()
162+
os.system(
163+
"openmc_data_downloader -l ENDFB-7.1-NNDC TENDL-2019 -e Be --no-overwrite",
164+
)
165+
time_after_download = time.time()
166+
time_to_not_download = time_after_download - current_time
167+
168+
assert time_to_not_download < time_to_download

0 commit comments

Comments
 (0)