Skip to content

Commit

Permalink
Update to PurePath
Browse files Browse the repository at this point in the history
  • Loading branch information
k8culver committed Dec 31, 2024
1 parent 4761450 commit 26cc4b4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
from pathlib import Path, PurePath
from typing import TYPE_CHECKING, List, Optional

import dimod
Expand Down Expand Up @@ -415,12 +416,15 @@ def write_input_data(data: dict, input_filename: Optional[str] = None) -> str:
)

if input_filename is not None:
if len(input_filename.split(".")) < 2:
input_filename = input_filename + ".txt"
input_file = PurePath(input_filename)

full_file_path = os.path.join("input", input_filename)
f = open(full_file_path, "w")
f.write(input_string)
f.close()
if input_file.suffix != ".txt":
input_file = input_file.with_suffix('.txt')

input_folder = Path(__file__).parent / "input"
file_path = input_folder / input_file.name

with Path(file_path).open("w") as f:
f.write(input_string)

return input_string

0 comments on commit 26cc4b4

Please sign in to comment.