project map script | semantic parcer
This commit is contained in:
@@ -42,7 +42,7 @@ class APIClient:
|
||||
self._tokens: Dict[str, str] = {}
|
||||
self._authenticated = False
|
||||
self.logger.info("[APIClient.__init__][Exit] APIClient initialized.")
|
||||
# [/DEF:APIClient.__init__]
|
||||
# [/DEF:APIClient.__init__:Function]
|
||||
|
||||
# [DEF:APIClient._init_session:Function]
|
||||
# @PURPOSE: Создает и настраивает `requests.Session` с retry-логикой.
|
||||
@@ -58,7 +58,7 @@ class APIClient:
|
||||
self.logger.warning("[_init_session][State] SSL verification disabled.")
|
||||
session.verify = self.request_settings["verify_ssl"]
|
||||
return session
|
||||
# [/DEF:APIClient._init_session]
|
||||
# [/DEF:APIClient._init_session:Function]
|
||||
|
||||
# [DEF:APIClient.authenticate:Function]
|
||||
# @PURPOSE: Выполняет аутентификацию в Superset API и получает access и CSRF токены.
|
||||
@@ -85,7 +85,7 @@ class APIClient:
|
||||
raise AuthenticationError(f"Authentication failed: {e}") from e
|
||||
except (requests.exceptions.RequestException, KeyError) as e:
|
||||
raise NetworkError(f"Network or parsing error during authentication: {e}") from e
|
||||
# [/DEF:APIClient.authenticate]
|
||||
# [/DEF:APIClient.authenticate:Function]
|
||||
|
||||
@property
|
||||
def headers(self) -> Dict[str, str]:
|
||||
@@ -98,7 +98,7 @@ class APIClient:
|
||||
"Referer": self.base_url,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
# [/DEF:APIClient.headers]
|
||||
# [/DEF:APIClient.headers:Function]
|
||||
|
||||
# [DEF:APIClient.request:Function]
|
||||
# @PURPOSE: Выполняет универсальный HTTP-запрос к API.
|
||||
@@ -121,7 +121,7 @@ class APIClient:
|
||||
self._handle_http_error(e, endpoint)
|
||||
except requests.exceptions.RequestException as e:
|
||||
self._handle_network_error(e, full_url)
|
||||
# [/DEF:APIClient.request]
|
||||
# [/DEF:APIClient.request:Function]
|
||||
|
||||
# [DEF:APIClient._handle_http_error:Function]
|
||||
# @PURPOSE: (Helper) Преобразует HTTP ошибки в кастомные исключения.
|
||||
@@ -133,7 +133,7 @@ class APIClient:
|
||||
if status_code == 403: raise PermissionDeniedError() from e
|
||||
if status_code == 401: raise AuthenticationError() from e
|
||||
raise SupersetAPIError(f"API Error {status_code}: {e.response.text}") from e
|
||||
# [/DEF:APIClient._handle_http_error]
|
||||
# [/DEF:APIClient._handle_http_error:Function]
|
||||
|
||||
# [DEF:APIClient._handle_network_error:Function]
|
||||
# @PURPOSE: (Helper) Преобразует сетевые ошибки в `NetworkError`.
|
||||
@@ -144,7 +144,7 @@ class APIClient:
|
||||
elif isinstance(e, requests.exceptions.ConnectionError): msg = "Connection error"
|
||||
else: msg = f"Unknown network error: {e}"
|
||||
raise NetworkError(msg, url=url) from e
|
||||
# [/DEF:APIClient._handle_network_error]
|
||||
# [/DEF:APIClient._handle_network_error:Function]
|
||||
|
||||
# [DEF:APIClient.upload_file:Function]
|
||||
# @PURPOSE: Загружает файл на сервер через multipart/form-data.
|
||||
@@ -170,7 +170,7 @@ class APIClient:
|
||||
raise TypeError(f"Unsupported file_obj type: {type(file_obj)}")
|
||||
|
||||
return self._perform_upload(full_url, files_payload, extra_data, _headers, timeout)
|
||||
# [/DEF:APIClient.upload_file]
|
||||
# [/DEF:APIClient.upload_file:Function]
|
||||
|
||||
# [DEF:APIClient._perform_upload:Function]
|
||||
# @PURPOSE: (Helper) Выполняет POST запрос с файлом.
|
||||
@@ -196,7 +196,7 @@ class APIClient:
|
||||
raise SupersetAPIError(f"API error during upload: {e.response.text}") from e
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise NetworkError(f"Network error during upload: {e}", url=url) from e
|
||||
# [/DEF:APIClient._perform_upload]
|
||||
# [/DEF:APIClient._perform_upload:Function]
|
||||
|
||||
# [DEF:APIClient.fetch_paginated_count:Function]
|
||||
# @PURPOSE: Получает общее количество элементов для пагинации.
|
||||
@@ -207,7 +207,7 @@ class APIClient:
|
||||
def fetch_paginated_count(self, endpoint: str, query_params: Dict, count_field: str = "count") -> int:
|
||||
response_json = cast(Dict[str, Any], self.request("GET", endpoint, params={"q": json.dumps(query_params)}))
|
||||
return response_json.get(count_field, 0)
|
||||
# [/DEF:APIClient.fetch_paginated_count]
|
||||
# [/DEF:APIClient.fetch_paginated_count:Function]
|
||||
|
||||
# [DEF:APIClient.fetch_paginated_data:Function]
|
||||
# @PURPOSE: Автоматически собирает данные со всех страниц пагинированного эндпоинта.
|
||||
@@ -225,8 +225,8 @@ class APIClient:
|
||||
response_json = cast(Dict[str, Any], self.request("GET", endpoint, params={"q": json.dumps(query)}))
|
||||
results.extend(response_json.get(results_field, []))
|
||||
return results
|
||||
# [/DEF:APIClient.fetch_paginated_data]
|
||||
# [/DEF:APIClient.fetch_paginated_data:Function]
|
||||
|
||||
# [/DEF:APIClient]
|
||||
# [/DEF:APIClient:Class]
|
||||
|
||||
# [/DEF:superset_tool.utils.network]
|
||||
# [/DEF:superset_tool.utils.network:Module]
|
||||
|
||||
Reference in New Issue
Block a user