Page MenuHomePhabricator
Paste P7316

T122763
ActivePublic

Authored by Dalba on Jun 29 2018, 4:21 PM.
Tags
None
Referenced Files
F23076048: T122763
Jun 29 2018, 4:21 PM
Subscribers
None
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 0d1785c5..6952fd47 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -558,6 +558,7 @@ class ParamInfo(Container):
# query modules can be prefixed with 'query+'
self._init()
+ modules = self._modules_to_set(modules)
if self._action_modules:
# The query module may be added before the action modules have been
if 'query' in self._modules:
@@ -738,12 +739,23 @@ class ParamInfo(Container):
assert param['name'] == 'generator' and \
submodules >= set(param['type'])
- def _normalize_modules(self, modules):
- """Add query+ to any query module name not also in action modules."""
- # Users will supply the wrong type, and expect it to work.
+ @staticmethod
+ def _modules_to_set(modules):
+ """Return set of modules.
+
+ @type modules: Iterable or str
+ @rtype: set
+ """
if isinstance(modules, basestring):
- modules = set(modules.split('|'))
+ return set(modules.split('|'))
+ return set(modules)
+ def _normalize_modules(self, modules):
+ """Add query+ to any query module name not also in action modules.
+
+ @type modules: set
+ @rtype: set
+ """
assert(self._action_modules)
return {'query+' + mod
@@ -762,7 +774,7 @@ class ParamInfo(Container):
@rtype: set
"""
self._init()
- return self._normalize_modules(modules)
+ return self._normalize_modules(self._modules_to_set(modules))
@classmethod
def normalize_paraminfo(cls, data):

Event Timeline

Note that _normalize_modules is private and was only used in ParamInfo.normalize_modules and ParamInfo.fetch.

I've removed conversion to set logic from _normalize_modules and instead added a helper function _modules_to_set which is called before calling _normalize_modules.

The new _normalize_modules only accepts a set as the parameter.