Skip to content

Commit

Permalink
-Sorting now works correctly
Browse files Browse the repository at this point in the history
-Sorting is now done by default. I chose to do this because in most instances you would like to make a call to all plugins, either it is a network related call where it is important to hit the least failed sites first in order to try and avoid hitting less hit sites, or you don't really care and it doesn't matter if it's sorted.
  • Loading branch information
Themis3000 committed Aug 18, 2021
1 parent ee5b9a4 commit b26a7dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/FreeProxyScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ class ProxyQuery(Plugins):
"""Handles the querying and operations of plugins"""

@GenLimiter
def exec_iter_plugin(self, method_name: str, sort_asc_fails: bool = False, *args, **kwargs) -> Iterator[Proxy]:
def exec_iter_plugin(self, method_name: str, sort_asc_fails: bool = True, *args, **kwargs) -> Iterator[Proxy]:
"""Executes a given method in all plugins that return an iterable, then returns an iterable that loops through
each plugins iterable"""
plugins = self.plugins.sort(key=lambda plugin: plugin.fails) if sort_asc_fails else self.plugins
if sort_asc_fails:
self.plugins.sort(key=lambda plugin: plugin.fails)

for plugin in plugins:
for plugin in self.plugins:
try:
method = getattr(plugin, method_name)
return_iter = method(*args, **kwargs)
Expand Down

0 comments on commit b26a7dc

Please sign in to comment.