Compare commits

..

2 Commits

Author SHA1 Message Date
slrover 227905dc04 Updated docs 2026-04-03 16:52:44 +03:00
slrover e03aed78f0 Fixed reports request 2026-04-03 16:48:44 +03:00
3 changed files with 21 additions and 17 deletions
+18 -14
View File
@@ -33,7 +33,7 @@ class Focus(Request):
return self.get('/egrDetails') return self.get('/egrDetails')
def excerpt(self, path: str = None) -> dict: def excerpt(self, path: str = None) -> dict:
"""Выписка из ЕГРЮЛ/ЕГРИП """Выписка из ЕГРЮЛ/ЕГРИП (только для РФ)
:param path: Путь выгрузки файла. Если не указан, выгружается в текущий каталог. :param path: Путь выгрузки файла. Если не указан, выгружается в текущий каталог.
:type path: str, необязательный :type path: str, необязательный
@@ -41,21 +41,25 @@ class Focus(Request):
:rtype: str :rtype: str
""" """
response = self.get('/excerpt') response = self.get('/excerpt')
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
if not path: if response.status_code != 404:
file_path = os.path.join(self._basedir, filename) current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
if not path:
file_path = os.path.join(self._basedir, filename)
else:
file_path = os.path.join(path, filename)
try:
with open(file_path, mode='wb') as file:
file.write(response.content)
return {'success': True, 'filename': filename, 'path': file_path}
except Exception as e:
return {'success': False, 'message': e}
else: else:
file_path = os.path.join(path, filename) return {'success': False, 'message': 'Not found'}
try:
with open(file_path, mode='wb') as file:
file.write(response.content)
return {'success': True, 'filename': filename, 'path': file_path}
except Exception as e:
return {'success': False, 'message': e}
def express_report(self, pdf: bool = True, path: str = None) -> dict: def express_report(self, pdf: bool = True, path: str = None) -> dict:
"""Экспресс-отчет по контрагенту """Экспресс-отчет по контрагенту
+2 -2
View File
@@ -36,8 +36,8 @@ class Request:
try: try:
response = requests.get(url=full_url, params=payload) response = requests.get(url=full_url, params=payload)
if response.headers['Content-Type'] == 'application/json' or \ if ('Content-Type' in response.headers and response.headers['Content-Type'] == 'application/json') or \
response.headers['Content-Type'] == 'application/json; charset=utf-8': ('Content-Type' in response.headers and response.headers['Content-Type'] == 'application/json; charset=utf-8'):
return response.json() return response.json()
else: else:
return response return response
+1 -1
View File
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="kontur_focus", name="kontur_focus",
version="2026.1.0", version="2026.4.3",
author="Ilya Sapunov", author="Ilya Sapunov",
author_email="me@slrover.ru", author_email="me@slrover.ru",
description="Библиотека-обертка для взаимодействия с REST API Контур.Фокус и Фокус.Комплаенс", description="Библиотека-обертка для взаимодействия с REST API Контур.Фокус и Фокус.Комплаенс",