John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/170885

Change subject: Allow ThreadGenerator param target to be iterable
......................................................................

Allow ThreadGenerator param target to be iterable

Detech if the param 'target' is iterable, and use it without
calling it first.

Change-Id: I02152fdbc8e32f4677fb839f18282350034a329e
---
M pywikibot/tools.py
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/85/170885/1

diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index 9254200..92e02b3 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -195,7 +195,12 @@
 
     def run(self):
         """Run the generator and store the results on the queue."""
-        self.__gen = self.generator(*self.args, **self.kwargs)
+        iterable = any([hasattr(self.generator, key)
+                        for key in ['__iter__', '__getitem__']])
+        if iterable and not self.args and not self.kwargs:
+            self.__gen = self.generator
+        else:
+            self.__gen = self.generator(*self.args, **self.kwargs)
         for result in self.__gen:
             while True:
                 if self.finished.isSet():

-- 
To view, visit https://gerrit.wikimedia.org/r/170885
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I02152fdbc8e32f4677fb839f18282350034a329e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to