hltv-async-api 0.2.7__tar.gz → 0.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hltv_async_api
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python
5
5
  Home-page: https://github.com/akimerslys/aiohltv
6
6
  Author: akimerslys
@@ -6,4 +6,4 @@
6
6
  from .aiohltv import Hltv
7
7
 
8
8
  __author__ = 'akimerslys'
9
- __version__ = '0.2.6'
9
+ __version__ = '0.2.8'
@@ -1,7 +1,7 @@
1
1
  from typing import Any, List
2
2
  from datetime import date, datetime, timedelta
3
3
  import pytz
4
-
4
+ import aiofiles
5
5
  from bs4 import BeautifulSoup
6
6
  import asyncio
7
7
  from asyncio import get_running_loop
@@ -76,11 +76,11 @@ class Hltv:
76
76
  self.DEBUG = debug
77
77
  self._configure_logging()
78
78
 
79
- def get_proxy(self):
79
+ async def get_proxy(self):
80
80
  proxy = ''
81
81
  if self.PROXY_PATH:
82
- with open(self.PROXY_PATH, "r") as file:
83
- new_proxy = file.readline().strip()
82
+ async with aiofiles.open(self.PROXY_PATH, "r") as file:
83
+ new_proxy = await file.readline().strip()
84
84
  if new_proxy:
85
85
  proxy = new_proxy
86
86
 
@@ -88,7 +88,7 @@ class Hltv:
88
88
  proxy = self.PROXY_LIST[0]
89
89
 
90
90
  if self.PROXY_PROTOCOL and proxy != '' and self.PROXY_PROTOCOL not in proxy:
91
- proxy = self.PROXY_PROTOCOL + '://' + proxy
91
+ proxy = self.PROXY_PROTOCOL + '://' + proxy
92
92
 
93
93
  return proxy
94
94
 
@@ -96,14 +96,14 @@ class Hltv:
96
96
  if self.PROXY_PATH:
97
97
  if self.PROXY_PROTOCOL:
98
98
  proxy = proxy.replace(self.PROXY_PROTOCOL + '://', '')
99
- with open(self.PROXY_PATH, "r+") as file:
100
- proxies = file.readlines()
101
- file.seek(0)
99
+ async with aiofiles.open(self.PROXY_PATH, "r+") as file:
100
+ proxies = await file.readlines()
101
+ await file.seek(0)
102
102
  for line in proxies:
103
103
  if line.strip() != proxy:
104
- file.write(line)
104
+ await file.write(line)
105
105
  if not self.REMOVE_PROXY:
106
- file.write(proxy + "\n")
106
+ await file.write(proxy + "\n")
107
107
  else:
108
108
  self.PROXY_LIST = self.PROXY_LIST[1:] + [self.PROXY_LIST[0]]
109
109
 
@@ -123,7 +123,7 @@ class Hltv:
123
123
  if self.USE_PROXY:
124
124
  self.logger.debug(f"Switching proxy {proxy}")
125
125
  await self.switch_proxy(proxy)
126
- self.logger.info(f"New proxy: {self.get_proxy()}")
126
+ self.logger.info(f"New proxy: {await self.get_proxy()}")
127
127
  else:
128
128
  if delay < self.MAX_DELAY:
129
129
  delay += 1
@@ -137,7 +137,7 @@ class Hltv:
137
137
  proxy = ''
138
138
  # setup new proxy, cuz old one was switched
139
139
  if self.USE_PROXY:
140
- proxy = self.get_proxy()
140
+ proxy = await self.get_proxy()
141
141
  else:
142
142
  # delay, only for non proxy users. (default = 1-15s)
143
143
  await asyncio.sleep(delay)
@@ -633,7 +633,6 @@ class Hltv:
633
633
 
634
634
  return players
635
635
 
636
- # TODO WRITE
637
636
  async def get_last_news(self, max_reg_news=2, only_today=True, only_featured=False):
638
637
  r = await self.fetch('https://www.hltv.org/')
639
638
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hltv_async_api
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python
5
5
  Home-page: https://github.com/akimerslys/aiohltv
6
6
  Author: akimerslys
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hltv_async_api"
3
- version = "0.2.7"
3
+ version = "0.2.8"
4
4
  authors = [
5
5
  { name="Akim Slys", email="akimslys2003@gmail.com" },
6
6
  ]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='hltv_async_api',
5
- version='0.2.7',
5
+ version='0.2.8',
6
6
  author='akimerslys',
7
7
  author_email='akimslys2003@gmail.com',
8
8
  description='Hltv-aio: An unofficial asynchronous HLTV API Wrapper for Python',
File without changes
File without changes
File without changes