jenkins-bot has submitted this change and it was merged.
Change subject: Reorder Option classes
......................................................................
Reorder Option classes
Place ListOption near by its superclass IntegerOption and ContextOption near
by NestedOption which are both inherited from OutputOption and StandardOption.
Change-Id: Ic66d0aba4401ffc5767d9c2d036fed32b7490d2d
---
M pywikibot/bot_choice.py
1 file changed, 29 insertions(+), 28 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index e116847..64cce6c 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -173,6 +173,35 @@
pywikibot.output(self._output)
+class ContextOption(OutputOption, StandardOption):
+
+ """An option to show more and more context."""
+
+ def __init__(self, option, shortcut, text, context, delta=100, start=0, end=0):
+ """Constructor."""
+ super(ContextOption, self).__init__(option, shortcut, False)
+ self.text = text
+ self.context = context
+ self.delta = delta
+ self.start = start
+ self.end = end
+
+ def result(self, value):
+ """Add the delta to the context and output it."""
+ self.context += self.delta
+ super(ContextOption, self).result(value)
+
+ def output(self):
+ """Output the context."""
+ start = max(0, self.start - self.context)
+ end = min(len(self.text), self.end + self.context)
+ self.output_range(start, end)
+
+ def output_range(self, start_context, end_context):
+ """Output a section from the text."""
+ pywikibot.output(self.text[start_context:end_context])
+
+
class IntegerOption(Option):
"""An option allowing a range of integers."""
@@ -248,34 +277,6 @@
def result(self, value):
"""Return the value converted into int."""
return (self.prefix, self.parse(value))
-
-
-class ContextOption(OutputOption, StandardOption):
-
- """An option to show more and more context."""
-
- def __init__(self, option, shortcut, text, context, delta=100, start=0, end=0):
- """Constructor."""
- super(ContextOption, self).__init__(option, shortcut, False)
- self.text = text
- self.context = context
- self.delta = delta
- self.start = start
- self.end = end
-
- def result(self, value):
- """Add the delta to the context."""
- self.context += self.delta
-
- def output(self):
- """Output the context."""
- start = max(0, self.start - self.context)
- end = min(len(self.text), self.end + self.context)
- self.output_range(start, end)
-
- def output_range(self, start_context, end_context):
- """Output a section from the text."""
- pywikibot.output(self.text[start_context:end_context])
class ListOption(IntegerOption):
--
To view, visit
https://gerrit.wikimedia.org/r/224748
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic66d0aba4401ffc5767d9c2d036fed32b7490d2d
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>