Revision: 4075 Author: wikipedian Date: 2007-08-19 13:22:49 +0000 (Sun, 19 Aug 2007)
Log Message: ----------- bugfix: displaying context when the link is near the beginning of the article
Modified Paths: -------------- trunk/pywikipedia/disambredir.py trunk/pywikipedia/selflink.py trunk/pywikipedia/solve_disambiguation.py trunk/pywikipedia/unlink.py
Modified: trunk/pywikipedia/disambredir.py =================================================================== --- trunk/pywikipedia/disambredir.py 2007-08-19 13:19:06 UTC (rev 4074) +++ trunk/pywikipedia/disambredir.py 2007-08-19 13:22:49 UTC (rev 4075) @@ -46,7 +46,7 @@ context = 30 # at the beginning of the link, start red color. # at the end of the link, reset the color to default - wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) + wikipedia.output(text[max(0, m.start() - context) : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) while True: choice = wikipedia.input(u"Option (n=do not change, y=change link to \03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)"%targetPage.title()) try:
Modified: trunk/pywikipedia/selflink.py =================================================================== --- trunk/pywikipedia/selflink.py 2007-08-19 13:19:06 UTC (rev 4074) +++ trunk/pywikipedia/selflink.py 2007-08-19 13:22:49 UTC (rev 4075) @@ -108,7 +108,7 @@ else: # at the beginning of the link, start red color. # at the end of the link, reset the color to default - wikipedia.output(text[match.start() - context : match.start()] + '\03{lightred}' + text[match.start() : match.end()] + '\03{default}' + text[match.end() : match.end() + context]) + wikipedia.output(text[match.start() - context) : match.start()] + '\03{lightred}' + text[match.start() : match.end()] + '\03{default}' + text[match.end() : match.end() + context]) choice = wikipedia.inputChoice(u'\nWhat shall be done with this selflink?', ['unlink', 'make bold', 'skip', 'edit', 'more context'], ['U', 'b', 's', 'e', 'm'], 'u') wikipedia.output(u'')
Modified: trunk/pywikipedia/solve_disambiguation.py =================================================================== --- trunk/pywikipedia/solve_disambiguation.py 2007-08-19 13:19:06 UTC (rev 4074) +++ trunk/pywikipedia/solve_disambiguation.py 2007-08-19 13:22:49 UTC (rev 4075) @@ -583,7 +583,7 @@
# at the beginning of the link, start red color. # at the end of the link, reset the color to default - wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) + wikipedia.output(text[max(0, m.start() - context) : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context])
if not self.always: if edited:
Modified: trunk/pywikipedia/unlink.py =================================================================== --- trunk/pywikipedia/unlink.py 2007-08-19 13:19:06 UTC (rev 4074) +++ trunk/pywikipedia/unlink.py 2007-08-19 13:22:49 UTC (rev 4075) @@ -75,7 +75,7 @@ else: # at the beginning of the link, start red color. # at the end of the link, reset the color to default - wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) + wikipedia.output(text[max(0, m.start() - context) : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) choice = wikipedia.inputChoice(u'\nWhat shall be done with this link?', ['unlink', 'skip', 'edit', 'more context'], ['U', 's', 'e', 'm'], 'u') wikipedia.output(u'')