diff --git a/domaintools/api.py b/domaintools/api.py index 8a00f01..e5215c0 100644 --- a/domaintools/api.py +++ b/domaintools/api.py @@ -1,12 +1,14 @@ from datetime import datetime, timedelta, timezone from hashlib import sha1, sha256 from hmac import new as hmac +from pathlib import Path from typing import Union import re import ssl import yaml + from domaintools.constants import ( Endpoint, OutputFormat, @@ -111,9 +113,11 @@ def __init__( raise Exception("Proxy URL must be a string. For example: '127.0.0.1:8888'") def _initialize_specs(self): + package_root = Path(__file__).parent for spec_name, file_path in SPECS_MAPPING.items(): + specs_file_path = f"{package_root}/specs/{file_path}" try: - with open(file_path, "r", encoding="utf-8") as f: + with open(specs_file_path, "r", encoding="utf-8") as f: spec_content = yaml.safe_load(f) if not spec_content: raise ValueError("Spec file is empty or invalid.") @@ -121,7 +125,7 @@ def _initialize_specs(self): self.specs[spec_name] = spec_content except Exception as e: - print(f"Error loading {file_path}: {e}") + print(f"Error loading {specs_file_path}: {e}") def _get_ssl_default_context(self, verify_ssl: Union[str, bool]): return ( diff --git a/domaintools/constants.py b/domaintools/constants.py index b000a26..4acee15 100644 --- a/domaintools/constants.py +++ b/domaintools/constants.py @@ -58,6 +58,6 @@ class OutputFormat(Enum): } SPECS_MAPPING = { - "iris": "domaintools/specs/iris-openapi.yaml", - # "rttf": "domaintools/specs/feeds-openapi.yaml", + "iris": "iris-openapi.yaml", + # "rttf": "feeds-openapi.yaml", }