Skip to content

Commit

Permalink
release v1.1.5 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeN220 authored Jul 7, 2023
2 parents 8e5b6e2 + ac722ee commit 2e20638
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ level = 20
format = [%%(levelname)s] %%(asctime)s - %%(name)s - %%(message)s
```
`level` - Уровень логирования. <br>
`format` - Формат логов. (Из-за особенностей файла .ini символ '%' нужно экранировать)
`format` - Формат логов.

# Как его запустить?

Expand Down
2 changes: 1 addition & 1 deletion config.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ id = 1

[logging]
level = 20
format = [%%(levelname)s] %%(asctime)s - %%(name)s - %%(message)s
format = [%(levelname)s] %(asctime)s - %(name)s - %(message)s
3 changes: 2 additions & 1 deletion src/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import urllib.parse

from src.config import Config
from src.market import MarketAPI, MarketBuyError, MarketItem
Expand Down Expand Up @@ -38,7 +39,7 @@ def main():
logging.info(
"По запросу %s с параметрами %s найдено %s аккаунтов",
search,
params,
urllib.parse.unquote(params),
len(items),
)

Expand Down
4 changes: 2 additions & 2 deletions src/config/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from configparser import ConfigParser
from configparser import ConfigParser, ExtendedInterpolation
from dataclasses import dataclass
from typing import List

Expand Down Expand Up @@ -32,7 +32,7 @@ class Config:

@classmethod
def load_config(cls, filename: str) -> "Config":
raw_config = ConfigParser()
raw_config = ConfigParser(interpolation=ExtendedInterpolation())
raw_config.read(filename, encoding="utf-8")
if not raw_config.sections():
raise FileNotFoundError(f"File {filename} is not defined")
Expand Down
2 changes: 1 addition & 1 deletion src/market/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def search(self, category: str, search_params: str) -> dict:


def parse_search_data(search_url: str) -> Optional[Tuple[str, str]]:
parse = re.search(r"https://lzt.market/([\w\-]+)/(.+)", search_url)
parse = re.search(r"https://lzt.market/([\w\-]+)/\?(.+)", search_url)
if not parse:
raise TypeError("Format search URL is invalid")
category, search_params = parse.groups()
Expand Down
11 changes: 10 additions & 1 deletion src/telegram/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import ssl
from typing import Optional
from urllib import parse, request

Expand All @@ -25,7 +26,8 @@ def api_request(
data=request_data,
method=request_method,
)
with request.urlopen(api_request) as response_object:
context = _get_disable_ssl()
with request.urlopen(api_request, context=context) as response_object:
response = json.load(response_object)
return response

Expand All @@ -35,3 +37,10 @@ def send_message(self, text: str, chat_id: int, **kwargs) -> dict:
{"text": text, "chat_id": chat_id, **kwargs},
)
return response


def _get_disable_ssl() -> ssl.SSLContext:
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
return context

0 comments on commit 2e20638

Please sign in to comment.