Skip to content

Commit 736d427

Browse files
committed
Remove redundant file.exists() check
Eliminated the check in `create_or_update_repository_file` in favor of that in `copy_previous_version_or_create_new_file_if_missing`.
1 parent 816cf5e commit 736d427

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

scripts/create_repository.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,21 @@ def create_current_resolved_artifacts_map(original_artifacts):
329329
)
330330
return result
331331

332-
def copy_previous_version_or_create_new_empty_file(file_path, output_dir_path):
332+
def copy_previous_version_or_create_new_file_if_missing(file_path, output_dir):
333333
if file_path.exists():
334334
return
335335

336-
existing_files = sorted(output_dir_path.glob('scala_*.bzl'))
336+
existing_files = sorted(output_dir.glob('scala_*.bzl'))
337337
if existing_files:
338338
shutil.copyfile(existing_files[-1], file_path)
339339
return
340340

341-
# Create an empty dictionary and start from scratch.
342341
with open(file_path, 'w', encoding='utf-8') as f:
343342
f.write('{}\n')
344343

345-
def create_or_update_repository_file(version, output_dir_path):
346-
file = output_dir_path / f'scala_{"_".join(version.split(".")[:2])}.bzl'
347-
348-
if not file.exists():
349-
copy_previous_version_or_create_new_empty_file(file, output_dir_path)
344+
def create_or_update_repository_file(version, output_dir):
345+
file = output_dir / f'scala_{"_".join(version.split(".")[:2])}.bzl'
346+
copy_previous_version_or_create_new_file_if_missing(file, output_dir)
350347

351348
print('\nUPDATING:', file)
352349
with file.open('r', encoding='utf-8') as data:

0 commit comments

Comments
 (0)