Skip to content

Commit 11b6d95

Browse files
committed
revise imports
1 parent 378c775 commit 11b6d95

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/electiondata/userinterface/__init__.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import json
1010
from numpy import where
1111
from os import walk, listdir
12-
from os.path import join, isdir, isfile
12+
import os.path
1313
import pandas as pd
1414
from pathlib import Path
1515
import shutil
@@ -449,15 +449,15 @@ def copy_directory_with_backup(
449449
<backup_suffix>"""
450450
err = None
451451
# if the original to be copied is actually a directory
452-
if isdir(original_path):
452+
if os.path.isdir(original_path):
453453
if backup_suffix:
454454
# make backup of anything with existing name
455-
if isdir(copy_path):
455+
if os.path.isdir(copy_path):
456456
shutil.move(copy_path, f"{copy_path}{backup_suffix}")
457457
print(f"Moved {copy_path} to {copy_path}{backup_suffix}")
458-
elif isfile(copy_path):
458+
elif os.path.isfile(copy_path):
459459
old_stem = Path(copy_path).stem
460-
backup_path = join(
460+
backup_path = os.path.join(
461461
Path(copy_path).parent,
462462
f"{old_stem}{backup_suffix}.{Path(copy_path).suffix}",
463463
)
@@ -491,8 +491,8 @@ def copy_with_err_handling(
491491
for root, dirs, files in walk(original_path, topdown=True):
492492
new_root = root.replace(original_path, copy_path)
493493
for f in files:
494-
old = join(root, f)
495-
new = join(new_root, f)
494+
old = os.path.join(root, f)
495+
new = os.path.join(new_root, f)
496496
try:
497497
shutil.copy(old, new)
498498
print(f"Copied {old} to {new}")
@@ -505,7 +505,7 @@ def copy_with_err_handling(
505505
f"Error while copying {old} to {new}:\n{she}",
506506
)
507507
for d in dirs:
508-
Path(join(new_root, d)).mkdir(parents=True, exist_ok=True)
508+
Path(os.path.join(new_root, d)).mkdir(parents=True, exist_ok=True)
509509
return err
510510

511511

@@ -638,12 +638,12 @@ def report(
638638

639639
if err_warn and [k for k in err_warn.keys() if err_warn[k]]:
640640
# create reporting directory if it does not exist
641-
if isfile(output_location):
641+
if os.path.isfile(output_location):
642642
print(
643643
"Target directory for errors and warnings exists as a file. Nothing will be reported."
644644
)
645645
return None
646-
elif not isdir(output_location):
646+
elif not os.path.isdir(output_location):
647647
Path(output_location).mkdir(parents=True, exist_ok=True)
648648

649649
if not key_list:
@@ -694,7 +694,7 @@ def report(
694694
out_str = f"\n{et.title()} errors ({nk_name}):\n{msg[(et, nk)]}\n\n{warn_str}"
695695

696696
# write info to a .errors or .errors file named for the name_key <nk>
697-
out_path = join(
697+
out_path = os.path.join(
698698
output_location,
699699
slugify(
700700
f"{file_prefix}_{et}_{nk_name}.errors",
@@ -721,7 +721,7 @@ def report(
721721
# write output
722722
# write info to a .warnings file named for the error-type and name_key
723723

724-
out_path = join(
724+
out_path = os.path.join(
725725
output_location,
726726
slugify(
727727
f"{file_prefix}_{et}_{nk_name}.warnings",
@@ -829,7 +829,7 @@ def confirm_essential_info(
829829

830830
# loop through files
831831
for f in [f for f in listdir(directory) if f[-4:] == ".ini"]:
832-
p_path = join(directory, f)
832+
p_path = os.path.join(directory, f)
833833
file_confirmed = False
834834
while not file_confirmed:
835835
param_dict, err = get_parameters(
@@ -880,7 +880,7 @@ def election_juris_list(ini_path: str, results_path: Optional[str] = None) -> li
880880
for subdir, dirs, files in walk(ini_path):
881881
for f in files:
882882
if (f.endswith(".ini")) and (not f.endswith("template.ini")):
883-
full_path = join(subdir, f)
883+
full_path = os.path.join(subdir, f)
884884
d, err = get_parameters(
885885
param_file=full_path,
886886
header="election_results",
@@ -891,7 +891,7 @@ def election_juris_list(ini_path: str, results_path: Optional[str] = None) -> li
891891
# if we're not checking against results directory, or if we are and the ini file
892892
# points to a file in or below the results directory
893893
if (not results_path) or (
894-
isfile(join(results_path, d["results_file"]))
894+
os.path.isfile(os.path.join(results_path, d["results_file"]))
895895
):
896896
# include the pair in the output
897897
ej_set.update({(d["election"], d["jurisdiction"])})

0 commit comments

Comments
 (0)