MCPcopy Index your code
hub / github.com/dbcli/pgcli / parse_service_info

Function parse_service_info

pgcli/main.py:1965–1989  ·  view source on GitHub ↗
(service)

Source from the content-addressed store, hash-verified

1963
1964
1965def parse_service_info(service):
1966 service = service or os.getenv("PGSERVICE")
1967 service_file = os.getenv("PGSERVICEFILE")
1968 if not service_file:
1969 # try ~/.pg_service.conf (if that exists)
1970 if platform.system() == "Windows":
1971 service_file = os.getenv("PGSYSCONFDIR") + "\\pg_service.conf"
1972 elif os.getenv("PGSYSCONFDIR"):
1973 service_file = os.path.join(os.getenv("PGSYSCONFDIR"), ".pg_service.conf")
1974 else:
1975 service_file = os.path.expanduser("~/.pg_service.conf")
1976 if not service or not os.path.exists(service_file):
1977 # nothing to do
1978 return None, service_file
1979 with open(service_file, newline="") as f:
1980 skipped_lines = skip_initial_comment(f)
1981 try:
1982 service_file_config = ConfigObj(f)
1983 except ParseError as err:
1984 err.line_number += skipped_lines
1985 raise err
1986 if service not in service_file_config:
1987 return None, service_file
1988 service_conf = service_file_config.get(service)
1989 return service_conf, service_file
1990
1991
1992def duration_in_words(duration_in_seconds: float) -> str:

Callers 1

connect_serviceMethod · 0.85

Calls 1

skip_initial_commentFunction · 0.85

Tested by

no test coverage detected