Last active
June 20, 2023 11:35
-
-
Save breinbaas/96799a68206161d8e2aff22a5917fc80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import subprocess | |
PATH_TO_DSTABILITY_CONSOLES = "D:\\Apps\\D-GEO Suite\\Consoles\\DStabilityConsole" | |
def case_insensitive_glob(filepath: str, fileextension: str) -> List[Path]: | |
p = Path(filepath) | |
result = [] | |
for filename in p.glob("**/*"): | |
if str(filename.suffix).lower() == fileextension.lower(): | |
result.append(filename.absolute()) | |
return result | |
def convert(path: str): | |
exe = Path(PATH_TO_DSTABILITY_CONSOLES) / "D-Stability Migration Console.exe" | |
stix_files = case_insensitive_glob(path, ".stix") | |
for stix_file in stix_files: | |
new_file = Path(stix_file.parent.absolute() / f"{stix_file.stem}_new.stix") | |
subprocess.run([exe, stix_file, new_file]) | |
# test | |
if __name__ == "__main__": | |
convert("testdata/old_stix") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment