proxy-reader 2.0.0__tar.gz → 2.1.0__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.

Potentially problematic release.


This version of proxy-reader might be problematic. Click here for more details.

Files changed (25) hide show
  1. proxy_reader-2.1.0/PKG-INFO +48 -0
  2. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/__init__.py +1 -2
  3. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/proxy.py +1 -1
  4. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/reader.py +25 -23
  5. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/utils.py +4 -3
  6. proxy_reader-2.1.0/proxy_reader.egg-info/PKG-INFO +48 -0
  7. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader.egg-info/SOURCES.txt +2 -1
  8. proxy_reader-2.1.0/proxy_reader.egg-info/requires.txt +6 -0
  9. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/pyproject.toml +21 -21
  10. proxy_reader-2.1.0/tests/test_reader.py +193 -0
  11. proxy_reader-2.0.0/PKG-INFO +0 -54
  12. proxy_reader-2.0.0/proxy_reader.egg-info/PKG-INFO +0 -54
  13. proxy_reader-2.0.0/proxy_reader.egg-info/requires.txt +0 -2
  14. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/LICENSE +0 -0
  15. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/MANIFEST.in +0 -0
  16. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/README.md +0 -0
  17. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/_types.py +0 -0
  18. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/domains.py +0 -0
  19. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/logs_config.py +0 -0
  20. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/protocols/__init__.py +0 -0
  21. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/protocols/reader.py +0 -0
  22. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader/py.typed +0 -0
  23. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader.egg-info/dependency_links.txt +0 -0
  24. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/proxy_reader.egg-info/top_level.txt +0 -0
  25. {proxy_reader-2.0.0 → proxy_reader-2.1.0}/setup.cfg +0 -0
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxy-reader
3
+ Version: 2.1.0
4
+ Summary: Proxy reader for Python
5
+ Project-URL: Homepage, https://github.com/runetech0/proxy-reader
6
+ Project-URL: github, https://github.com/runetech0/proxy-reader
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: aiohttp>=3.12.15
11
+ Requires-Dist: aiohttp-socks>=0.10.1
12
+ Requires-Dist: pytest>=8.4.1
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest>=7.0.0; extra == "test"
15
+ Dynamic: license-file
16
+
17
+
18
+
19
+
20
+ # proxy-reader - A simple but useful bulk proxies reader and checker.
21
+
22
+ This is useful when you are working with multiple proxies and want to bulk check
23
+ these proxies before using them.
24
+ It has iterators to iterate the proxies for easy reading.
25
+
26
+
27
+ ## Installation
28
+
29
+ ```
30
+ pip install proxy-reader
31
+ ```
32
+
33
+ ## Changelogs
34
+
35
+ ### [v0.3.0]
36
+ * Add load_list class method to load proxies from list
37
+ * MAJOR: auto detect the proxies format
38
+ * Use new logging config to disable logs and prevent proxy_reader.log from creating
39
+ * Logs can be enabled from user-side
40
+ * Add option to disable proxies checking from __init__
41
+
42
+
43
+ ### [v0.2.0] - 2024-10-21
44
+
45
+ * Previous unrecorded changes
46
+
47
+
48
+ For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -1,4 +1,3 @@
1
1
  from .reader import *
2
2
 
3
-
4
- __version__ = "2.0.0"
3
+ __version__ = "2.1.0"
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
- from typing import TYPE_CHECKING, Optional, Dict, Any
3
2
 
3
+ from typing import TYPE_CHECKING, Any, Dict, Optional
4
4
 
5
5
  if TYPE_CHECKING:
6
6
  from ._types import GeneralDict, ProxyDictT
@@ -1,18 +1,20 @@
1
+ import asyncio
2
+ import itertools
1
3
  import os
2
4
  import random
3
- import itertools
5
+ import sys
4
6
  import tempfile
5
7
  import warnings
6
- from .utils import parse_proxy_line
7
- from .proxy import Proxy
8
+ from typing import Any
9
+
8
10
  import aiohttp
9
- import asyncio
10
- from .logs_config import logger
11
11
  from aiohttp_socks import ProxyConnector
12
- import sys
13
- from typing import Optional, List, Dict, Any
12
+
14
13
  from ._types import ProxiesList, ProxyDictT, ProxyiesGen
14
+ from .logs_config import logger
15
15
  from .protocols.reader import ProxiesReaderProtocol
16
+ from .proxy import Proxy
17
+ from .utils import parse_proxy_line
16
18
 
17
19
 
18
20
  class ProxiesReader(ProxiesReaderProtocol):
@@ -39,8 +41,8 @@ class ProxiesReader(ProxiesReaderProtocol):
39
41
  [] if self._check_proxies else self._all_proxies
40
42
  )
41
43
 
42
- self._proxy_iterator: Optional[ProxyiesGen] = None
43
- self._proxy_iterator_cycle: Optional[ProxyiesGen] = None
44
+ self._proxy_iterator: ProxyiesGen | None = None
45
+ self._proxy_iterator_cycle: ProxyiesGen | None = None
44
46
  self._thread_control: asyncio.Semaphore = asyncio.Semaphore(
45
47
  proxy_checking_threads
46
48
  )
@@ -168,7 +170,7 @@ class ProxiesReader(ProxiesReaderProtocol):
168
170
  random.shuffle(self._all_proxies)
169
171
 
170
172
  async def _check_proxy(
171
- self, proxy: Proxy, response_time: Optional[int] = None
173
+ self, proxy: Proxy, response_time: int | None = None
172
174
  ) -> bool:
173
175
  connectins_limit = 60 if "win" in sys.platform else 100
174
176
  connector = aiohttp.TCPConnector(limit=connectins_limit)
@@ -223,7 +225,7 @@ class ProxiesReader(ProxiesReaderProtocol):
223
225
  logger.debug("All proxies checked.")
224
226
 
225
227
  async def _check_proxy_socks(
226
- self, proxy: Proxy, response_time: Optional[int] = None
228
+ self, proxy: Proxy, response_time: int | None = None
227
229
  ) -> bool:
228
230
  url = self._random_proxy_check_url()
229
231
  socks_connector = ProxyConnector.from_url(proxy.socks5) # type: ignore
@@ -256,7 +258,7 @@ class ProxiesReader(ProxiesReaderProtocol):
256
258
 
257
259
  async def check_all_proxies_socks5(self, max_resp_time: int = 5) -> None:
258
260
  """Run the check on all proxies at once."""
259
- tasks: List[asyncio.Task[bool]] = []
261
+ tasks: list[asyncio.Task[bool]] = []
260
262
  for proxy in self._all_proxies:
261
263
  tasks.append(
262
264
  asyncio.create_task(self._check_proxy_socks(proxy, max_resp_time))
@@ -265,8 +267,8 @@ class ProxiesReader(ProxiesReaderProtocol):
265
267
  self._proxies_checked = True
266
268
  logger.debug("All proxies checked.")
267
269
 
268
- def get_working_proxies_list_http(self) -> List[str]:
269
- working_list: List[str] = []
270
+ def get_working_proxies_list_http(self) -> list[str]:
271
+ working_list: list[str] = []
270
272
  for proxy in self._working_proxies:
271
273
  working_list.append(proxy.http)
272
274
  return working_list
@@ -278,28 +280,28 @@ class ProxiesReader(ProxiesReaderProtocol):
278
280
  f.write("\n".join([proxy.strip() for proxy in working_list]))
279
281
  logger.debug(f"Proxies written to: {filename}")
280
282
 
281
- def get_random_http(self) -> Optional[str]:
283
+ def get_random_http(self) -> str | None:
282
284
  _p = None
283
285
  if len(self._working_proxies) > 0:
284
286
  proxy = random.choice(self._working_proxies)
285
287
  _p = proxy.http
286
288
  return _p
287
289
 
288
- def get_random_socks5(self) -> Optional[str]:
290
+ def get_random_socks5(self) -> str | None:
289
291
  _p = None
290
292
  if len(self._working_proxies) > 0:
291
293
  proxy = random.choice(self._working_proxies)
292
294
  _p = proxy.socks5
293
295
  return _p
294
296
 
295
- def get_random_socks5_telegram(self) -> Optional[Dict[str, Any]]:
297
+ def get_random_socks5_telegram(self) -> dict[str, Any] | None:
296
298
  _p = None
297
299
  if len(self._working_proxies) > 0:
298
300
  proxy = random.choice(self._working_proxies)
299
301
  _p = proxy.telegram_socks5
300
302
  return _p
301
303
 
302
- def next_http_from_list(self) -> Optional[str]:
304
+ def next_http_from_list(self) -> str | None:
303
305
  """Get next proxy from proxies list"""
304
306
 
305
307
  def __iter() -> ProxyiesGen:
@@ -339,14 +341,14 @@ class ProxiesReader(ProxiesReaderProtocol):
339
341
  )
340
342
  return str(next(self._proxy_iterator_cycle).socks5)
341
343
 
342
- def next_http_telegram_from_list(self) -> Dict[str, Any]:
344
+ def next_http_telegram_from_list(self) -> dict[str, Any]:
343
345
  """Get next proxy from proxies list"""
344
346
 
345
347
  if self._proxy_iterator is None:
346
348
  self._proxy_iterator = self.__proxies_gen(self._working_proxies)
347
349
  return dict(next(self._proxy_iterator).telegram_http)
348
350
 
349
- def next_http_telegram_from_cycle(self) -> Dict[str, Any]:
351
+ def next_http_telegram_from_cycle(self) -> dict[str, Any]:
350
352
  """Get next proxy from proxies cycle"""
351
353
 
352
354
  if self._proxy_iterator is None:
@@ -355,7 +357,7 @@ class ProxiesReader(ProxiesReaderProtocol):
355
357
  )
356
358
  return dict(next(self._proxy_iterator).telegram_http)
357
359
 
358
- def next_socks5_telegram_from_cycle(self) -> Dict[str, Any]:
360
+ def next_socks5_telegram_from_cycle(self) -> dict[str, Any]:
359
361
  """Get next proxy from proxies cycle"""
360
362
  if self._proxy_iterator_cycle is None:
361
363
  self._proxy_iterator_cycle = self.__proxies_gen(
@@ -363,7 +365,7 @@ class ProxiesReader(ProxiesReaderProtocol):
363
365
  )
364
366
  return dict(next(self._proxy_iterator_cycle).telegram_socks5)
365
367
 
366
- def next_socks5_telegram_from_list(self) -> Dict[str, Any]:
368
+ def next_socks5_telegram_from_list(self) -> dict[str, Any]:
367
369
  """Get next proxy from proxies cycle"""
368
370
 
369
371
  if self._proxy_iterator_cycle is None:
@@ -389,7 +391,7 @@ class ProxiesReader(ProxiesReaderProtocol):
389
391
  return str(next(self._proxy_iterator_cycle).https)
390
392
 
391
393
  def __proxies_gen(
392
- self, proxies_list: List[Proxy], cycle_proxies: bool = False
394
+ self, proxies_list: list[Proxy], cycle_proxies: bool = False
393
395
  ) -> ProxyiesGen:
394
396
  if cycle_proxies:
395
397
  for proxy in itertools.cycle(self._working_proxies):
@@ -1,6 +1,7 @@
1
- from ._types import ProxyDictT
2
1
  import re
3
2
  from typing import cast
3
+
4
+ from ._types import ProxyDictT
4
5
  from .logs_config import logger
5
6
 
6
7
 
@@ -8,7 +9,7 @@ def parse_proxy_line(proxy: str) -> ProxyDictT:
8
9
  """
9
10
  Detects the format of the proxy string and extracts the components.
10
11
 
11
- Returns a dictionary with 'ip_or_host', 'port', 'username', and 'password'.
12
+ Returns a dictionary with 'host', 'port', 'username', and 'password'.
12
13
  """
13
14
  logger.info("Reading the proxy format ...")
14
15
  patterns: list[str] = [
@@ -21,7 +22,7 @@ def parse_proxy_line(proxy: str) -> ProxyDictT:
21
22
  # Format 4: USERNAME:PASSWORD@IP/Hostname:PORT
22
23
  r"^(?P<username>[^:]+):(?P<password>[^@]+)@(?P<host>[\w\.-]+):(?P<port>\d+)$",
23
24
  # Format 5: IP/Hostname:PORT (No Username/Password)
24
- r"^(?P<ip_or_host>[\w\.-]+):(?P<port>\d+)$",
25
+ r"^(?P<host>[\w\.-]+):(?P<port>\d+)$",
25
26
  ]
26
27
 
27
28
  for pattern in patterns:
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxy-reader
3
+ Version: 2.1.0
4
+ Summary: Proxy reader for Python
5
+ Project-URL: Homepage, https://github.com/runetech0/proxy-reader
6
+ Project-URL: github, https://github.com/runetech0/proxy-reader
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: aiohttp>=3.12.15
11
+ Requires-Dist: aiohttp-socks>=0.10.1
12
+ Requires-Dist: pytest>=8.4.1
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest>=7.0.0; extra == "test"
15
+ Dynamic: license-file
16
+
17
+
18
+
19
+
20
+ # proxy-reader - A simple but useful bulk proxies reader and checker.
21
+
22
+ This is useful when you are working with multiple proxies and want to bulk check
23
+ these proxies before using them.
24
+ It has iterators to iterate the proxies for easy reading.
25
+
26
+
27
+ ## Installation
28
+
29
+ ```
30
+ pip install proxy-reader
31
+ ```
32
+
33
+ ## Changelogs
34
+
35
+ ### [v0.3.0]
36
+ * Add load_list class method to load proxies from list
37
+ * MAJOR: auto detect the proxies format
38
+ * Use new logging config to disable logs and prevent proxy_reader.log from creating
39
+ * Logs can be enabled from user-side
40
+ * Add option to disable proxies checking from __init__
41
+
42
+
43
+ ### [v0.2.0] - 2024-10-21
44
+
45
+ * Previous unrecorded changes
46
+
47
+
48
+ For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -16,4 +16,5 @@ proxy_reader.egg-info/dependency_links.txt
16
16
  proxy_reader.egg-info/requires.txt
17
17
  proxy_reader.egg-info/top_level.txt
18
18
  proxy_reader/protocols/__init__.py
19
- proxy_reader/protocols/reader.py
19
+ proxy_reader/protocols/reader.py
20
+ tests/test_reader.py
@@ -0,0 +1,6 @@
1
+ aiohttp>=3.12.15
2
+ aiohttp-socks>=0.10.1
3
+ pytest>=8.4.1
4
+
5
+ [test]
6
+ pytest>=7.0.0
@@ -1,31 +1,26 @@
1
-
1
+ [project]
2
+ name = "proxy-reader"
3
+ version = "2.1.0"
4
+ description = "Proxy reader for Python"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "aiohttp>=3.12.15",
9
+ "aiohttp-socks>=0.10.1",
10
+ "pytest>=8.4.1",
11
+ ]
2
12
 
3
13
 
4
14
  [build-system]
5
-
6
- requires = ["setuptools>=61.0.0"]
15
+ requires = ["setuptools", "wheel"]
7
16
  build-backend = "setuptools.build_meta"
8
17
 
9
- [project]
10
18
 
11
- name = "proxy-reader"
12
- version = "2.0.0"
13
- description = "Read and check bulk proxies effectively"
14
- authors = [
15
- {name = "Rune Tech", email = "runetech2024@gmail.com"}
19
+ [project.optional-dependencies]
20
+ test = [
21
+ "pytest>=7.0.0",
16
22
  ]
17
23
 
18
- license = { file = "LICENSE" }
19
- readme = "README.md"
20
-
21
- dependencies = [
22
- "aiohttp >= 3.10.10",
23
- "aiohttp_socks >= 0.9.0",
24
- ]
25
- requires-python = ">=3.11"
26
-
27
- keywords = ["proxies" ,"proxy", "reader", "checker", "bulk"]
28
-
29
24
  [project.urls]
30
25
  Homepage = "https://github.com/runetech0/proxy-reader"
31
26
  github = "https://github.com/runetech0/proxy-reader"
@@ -33,7 +28,7 @@ github = "https://github.com/runetech0/proxy-reader"
33
28
 
34
29
  [tool.bumpver]
35
30
 
36
- current_version = "2.0.0"
31
+ current_version = "2.1.0"
37
32
  version_pattern = "MAJOR.MINOR.PATCH"
38
33
  commit_message = "bump version {old_version} -> {new_version}"
39
34
  tag_message = "{new_version}"
@@ -54,3 +49,8 @@ push = true
54
49
  "{version}",
55
50
  ]
56
51
 
52
+ [dependency-groups]
53
+ dev = [
54
+ "build>=1.2.2.post1",
55
+ ]
56
+
@@ -0,0 +1,193 @@
1
+ import os
2
+ import tempfile
3
+
4
+ import pytest
5
+
6
+ from proxy_reader.reader import ProxiesReader
7
+
8
+
9
+ class TestProxiesReader:
10
+ """Test cases for ProxiesReader class"""
11
+
12
+ def test_init_with_proxies_file(self) -> None:
13
+ """Test initializing ProxiesReader with proxies.txt file"""
14
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
15
+
16
+ assert reader.total == 5
17
+ assert (
18
+ reader.total_working == 5
19
+ ) # Since check_proxies=False, all proxies are considered working
20
+ assert reader.total_bad == 0
21
+ assert len(reader.proxies) == 5
22
+ assert len(reader.working_proxies) == 5
23
+ assert len(reader.bad_proxies) == 0
24
+
25
+ def test_init_with_check_proxies_true(self) -> None:
26
+ """Test initializing ProxiesReader with check_proxies=True"""
27
+ reader = ProxiesReader("proxies.txt", check_proxies=True)
28
+
29
+ assert reader.total == 5
30
+ assert (
31
+ reader.total_working == 0
32
+ ) # Initially empty since proxies haven't been checked yet
33
+ assert reader.total_bad == 0
34
+ assert len(reader.proxies) == 5
35
+ assert len(reader.working_proxies) == 0
36
+ assert len(reader.bad_proxies) == 0
37
+
38
+ def test_load_list_class_method(self) -> None:
39
+ """Test the load_list class method"""
40
+ proxy_list = ["192.168.1.1:8080", "10.0.0.1:3128"]
41
+ reader = ProxiesReader.load_list(proxy_list, check_proxies=False)
42
+
43
+ assert reader.total == 2
44
+ assert reader.total_working == 2
45
+ assert reader.total_bad == 0
46
+ assert len(reader.proxies) == 2
47
+ assert len(reader.working_proxies) == 2
48
+
49
+ def test_proxy_parsing(self) -> None:
50
+ """Test that proxies are parsed correctly"""
51
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
52
+
53
+ # Check that the proxy from proxies.txt is parsed correctly
54
+ proxy = reader.proxies[0]
55
+ assert proxy.ip == "23.95.150.145"
56
+ assert proxy.port == "6114"
57
+ assert proxy.http == "http://23.95.150.145:6114"
58
+ assert proxy.https == "https://23.95.150.145:6114"
59
+ assert proxy.socks5 == "socks5://23.95.150.145:6114"
60
+
61
+ def test_get_random_methods(self) -> None:
62
+ """Test get_random methods"""
63
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
64
+
65
+ # Test get_random_http
66
+ random_http = reader.get_random_http()
67
+ assert random_http == "http://23.95.150.145:6114"
68
+
69
+ # Test get_random_socks5
70
+ random_socks5 = reader.get_random_socks5()
71
+ assert random_socks5 == "socks5://23.95.150.145:6114"
72
+
73
+ def test_next_methods(self) -> None:
74
+ """Test next methods for getting proxies sequentially"""
75
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
76
+
77
+ # Test next_http_from_list
78
+ next_http = reader.next_http_from_list()
79
+ assert next_http == "http://23.95.150.145:6114"
80
+
81
+ # Test next_http_from_cycle
82
+ next_http_cycle = reader.next_http_from_cycle()
83
+ assert next_http_cycle == "http://23.95.150.145:6114"
84
+
85
+ # Test next_socks5_from_list
86
+ next_socks5 = reader.next_socks5_from_list()
87
+ assert next_socks5 == "socks5://23.95.150.145:6114"
88
+
89
+ # Test next_socks5_from_cycle
90
+ next_socks5_cycle = reader.next_socks5_from_cycle()
91
+ assert next_socks5_cycle == "socks5://23.95.150.145:6114"
92
+
93
+ def test_telegram_proxy_methods(self) -> None:
94
+ """Test Telegram proxy format methods"""
95
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
96
+
97
+ # Test next_http_telegram_from_list
98
+ telegram_http = reader.next_http_telegram_from_list()
99
+ assert isinstance(telegram_http, dict)
100
+ assert telegram_http["proxy_type"] == 3
101
+ assert telegram_http["addr"] == "23.95.150.145"
102
+ assert telegram_http["port"] == 6114
103
+
104
+ # Test next_http_telegram_from_cycle
105
+ telegram_http_cycle = reader.next_http_telegram_from_cycle()
106
+ assert isinstance(telegram_http_cycle, dict)
107
+ assert telegram_http_cycle["proxy_type"] == 3
108
+ assert telegram_http_cycle["addr"] == "23.95.150.145"
109
+ assert telegram_http_cycle["port"] == 6114
110
+
111
+ def test_write_working_proxies(self) -> None:
112
+ """Test writing working proxies to file"""
113
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
114
+
115
+ with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_file:
116
+ temp_filename = temp_file.name
117
+
118
+ try:
119
+ reader.write_working_proxies(temp_filename)
120
+
121
+ # Check that the file was created and contains the proxy
122
+ assert os.path.exists(temp_filename)
123
+ with open(temp_filename, "r") as f:
124
+ content = f.read().strip()
125
+ assert content == content
126
+ finally:
127
+ # Clean up
128
+ if os.path.exists(temp_filename):
129
+ os.unlink(temp_filename)
130
+
131
+ def test_get_working_proxies_list_http(self) -> None:
132
+ """Test getting list of working HTTP proxies"""
133
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
134
+
135
+ working_list = reader.get_working_proxies_list_http()
136
+ assert len(working_list) == 5
137
+ assert working_list[0] == "http://23.95.150.145:6114"
138
+
139
+ def test_str_and_repr(self) -> None:
140
+ """Test string representation methods"""
141
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
142
+
143
+ str_repr = str(reader)
144
+ repr_repr = repr(reader)
145
+
146
+ assert str_repr == repr_repr
147
+ assert "23.95.150.145:6114" in str_repr
148
+
149
+ def test_working_proxies_setter(self) -> None:
150
+ """Test working_proxies setter"""
151
+ reader = ProxiesReader("proxies.txt", check_proxies=False)
152
+
153
+ # Initially should have 1 working proxy
154
+ assert len(reader.working_proxies) == 5
155
+
156
+ # Set to empty list
157
+ reader.working_proxies = []
158
+ assert len(reader.working_proxies) == 0
159
+ assert reader.total_working == 0
160
+
161
+ def test_with_multiple_proxies(self) -> None:
162
+ """Test with multiple proxies in file"""
163
+ # Create temporary file with multiple proxies
164
+ with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_file:
165
+ temp_file.write("192.168.1.1:8080\n10.0.0.1:3128\n172.16.0.1:8080")
166
+ temp_filename = temp_file.name
167
+
168
+ try:
169
+ reader = ProxiesReader(temp_filename, check_proxies=False)
170
+
171
+ assert reader.total == 3
172
+ assert reader.total_working == 3
173
+ assert len(reader.proxies) == 3
174
+
175
+ # Test that we can get all proxies
176
+ working_list = reader.get_working_proxies_list_http()
177
+ assert len(working_list) == 3
178
+ assert "http://192.168.1.1:8080" in working_list
179
+ assert "http://10.0.0.1:3128" in working_list
180
+ assert "http://172.16.0.1:8080" in working_list
181
+ finally:
182
+ # Clean up
183
+ if os.path.exists(temp_filename):
184
+ os.unlink(temp_filename)
185
+
186
+ def test_file_not_found_error(self) -> None:
187
+ """Test that appropriate error is raised for non-existent file"""
188
+ with pytest.raises(FileNotFoundError):
189
+ ProxiesReader("non_existent_file.txt", check_proxies=False)
190
+
191
+
192
+ if __name__ == "__main__":
193
+ pytest.main([__file__])
@@ -1,54 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: proxy-reader
3
- Version: 2.0.0
4
- Summary: Read and check bulk proxies effectively
5
- Author-email: Rune Tech <runetech2024@gmail.com>
6
- License: The MIT License (MIT)
7
- Copyright © 2024 Rune Tech
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- Project-URL: Homepage, https://github.com/runetech0/proxy-reader
15
- Project-URL: github, https://github.com/runetech0/proxy-reader
16
- Keywords: proxies,proxy,reader,checker,bulk
17
- Requires-Python: >=3.11
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: aiohttp>=3.10.10
21
- Requires-Dist: aiohttp_socks>=0.9.0
22
-
23
-
24
-
25
-
26
- # proxy-reader - A simple but useful bulk proxies reader and checker.
27
-
28
- This is useful when you are working with multiple proxies and want to bulk check
29
- these proxies before using them.
30
- It has iterators to iterate the proxies for easy reading.
31
-
32
-
33
- ## Installation
34
-
35
- ```
36
- pip install proxy-reader
37
- ```
38
-
39
- ## Changelogs
40
-
41
- ### [v0.3.0]
42
- * Add load_list class method to load proxies from list
43
- * MAJOR: auto detect the proxies format
44
- * Use new logging config to disable logs and prevent proxy_reader.log from creating
45
- * Logs can be enabled from user-side
46
- * Add option to disable proxies checking from __init__
47
-
48
-
49
- ### [v0.2.0] - 2024-10-21
50
-
51
- * Previous unrecorded changes
52
-
53
-
54
- For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -1,54 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: proxy-reader
3
- Version: 2.0.0
4
- Summary: Read and check bulk proxies effectively
5
- Author-email: Rune Tech <runetech2024@gmail.com>
6
- License: The MIT License (MIT)
7
- Copyright © 2024 Rune Tech
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- Project-URL: Homepage, https://github.com/runetech0/proxy-reader
15
- Project-URL: github, https://github.com/runetech0/proxy-reader
16
- Keywords: proxies,proxy,reader,checker,bulk
17
- Requires-Python: >=3.11
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: aiohttp>=3.10.10
21
- Requires-Dist: aiohttp_socks>=0.9.0
22
-
23
-
24
-
25
-
26
- # proxy-reader - A simple but useful bulk proxies reader and checker.
27
-
28
- This is useful when you are working with multiple proxies and want to bulk check
29
- these proxies before using them.
30
- It has iterators to iterate the proxies for easy reading.
31
-
32
-
33
- ## Installation
34
-
35
- ```
36
- pip install proxy-reader
37
- ```
38
-
39
- ## Changelogs
40
-
41
- ### [v0.3.0]
42
- * Add load_list class method to load proxies from list
43
- * MAJOR: auto detect the proxies format
44
- * Use new logging config to disable logs and prevent proxy_reader.log from creating
45
- * Logs can be enabled from user-side
46
- * Add option to disable proxies checking from __init__
47
-
48
-
49
- ### [v0.2.0] - 2024-10-21
50
-
51
- * Previous unrecorded changes
52
-
53
-
54
- For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -1,2 +0,0 @@
1
- aiohttp>=3.10.10
2
- aiohttp_socks>=0.9.0
File without changes
File without changes
File without changes
File without changes