Andre Engels has uploaded a new change for review.

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

Change subject: allow ListOption to be called with an empty list
......................................................................

allow ListOption to be called with an empty list

Change-Id: Ie8a062b592dc01fea78fd859605d27c4da10e265
---
M pywikibot/bot_choice.py
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/00/270600/1

diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index af5bc28..7040caf 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -177,14 +177,14 @@
 
     """An option allowing a range of integers."""
 
-    def __init__(self, minimum=1, maximum=None, prefix=''):
+    def __init__(self, minimum=1, maximum=None, prefix='', 
allowemptyrange=False):
         """Constructor."""
         super(IntegerOption, self).__init__()
         if not ((minimum is None or isinstance(minimum, int)) and
                 (maximum is None or isinstance(maximum, int))):
             raise ValueError(
                 'The minimum and maximum parameters must be int or None.')
-        if minimum is not None and maximum is not None and minimum > maximum:
+        if minimum is not None and maximum is not None and minimum > maximum 
and not allowemptyrange:
             raise ValueError('The minimum must be lower than the maximum.')
         self._min = minimum
         self._max = maximum
@@ -287,7 +287,7 @@
         """Constructor."""
         self._list = sequence
         try:
-            super(ListOption, self).__init__(1, self.maximum, prefix)
+            super(ListOption, self).__init__(1, self.maximum, prefix, 
allowemptyrange = True)
         except ValueError:
             raise ValueError('The sequence is empty.')
         del self._max
@@ -295,7 +295,7 @@
     def format(self, default):
         """Return a string showing the range."""
         if not self._list:
-            raise ValueError('The sequence is empty.')
+            return ("")
         else:
             return super(ListOption, self).format(default)
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8a062b592dc01fea78fd859605d27c4da10e265
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Andre Engels <[email protected]>

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

Reply via email to