Skip to content

Commit

Permalink
Use the lib to get the proper Windows file path
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed May 16, 2024
1 parent 7d8c26c commit 3c3ff49
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pg_service_parser/core/pg_service_parser_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import platform
from os import getenv
from pathlib import Path
from typing import List, Optional

from pg_service_parser.libs import pgserviceparser


def conf_path() -> Path:
pg_config_path = None
if getenv("PGSERVICEFILE"):
pg_config_path = Path(getenv("PGSERVICEFILE"))
elif getenv("PGSYSCONFDIR"):
pg_config_path = Path(getenv("PGSYSCONFDIR")) / "pg_service.conf"
else:
if platform.system() == "Windows":
pg_config_path = Path(getenv("APPDATA")) / ".pg_service.conf"
else: # Linux or Darwin (TODO: verify Mac)
pg_config_path = Path("~/.pg_service.conf").expanduser()

return pg_config_path
return pgserviceparser.conf_path()


def service_names(conf_file_path: Optional[Path] = None) -> List[str]:
Expand All @@ -45,7 +32,7 @@ def create_service(
return False

config.add_section(service_name)
with open(str(conf_file_path), "w") as f:
with open(conf_file_path, "w") as f:
config.write(f)

if service_name in config:
Expand Down

0 comments on commit 3c3ff49

Please sign in to comment.