XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/184781
Change subject: [FIX] Flake8 on Python 3 fixes
......................................................................
[FIX] Flake8 on Python 3 fixes
This also changes how match_images in the match_images scripts return
the match value. Instead of being between 100 and 0 it's not between 1.0
and 0.0 so that the complete script is now using that range. It's in
theory breaking but because the name was pep8ified when converted to
core a few days ago it was broken anyway (and the old non-pep8 function
could be added to support the old 0-100 range if necessary).
Change-Id: I95ed0de30d2993d41a70c9b47b76c6461f40e8a0
---
M scripts/match_images.py
M scripts/upload.py
2 files changed, 12 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/81/184781/1
diff --git a/scripts/match_images.py b/scripts/match_images.py
index 304583b..9a356a8 100644
--- a/scripts/match_images.py
+++ b/scripts/match_images.py
@@ -87,21 +87,21 @@
averageScore = (wholeScore + topleftScore + toprightScore +
bottomleftScore + bottomrightScore + centerScore) / 6
- print (u'Whole image ' + str(wholeScore))
- print (u'Top left of image ' + str(topleftScore))
- print (u'Top right of image ' + str(toprightScore))
- print (u'Bottom left of image ' + str(bottomleftScore))
- print (u'Bottom right of image ' + str(bottomrightScore))
- print (u'Center of image ' + str(centerScore))
- print (u' -------------')
- print (u'Average ' + str(averageScore))
+ pywikibot.output('Whole image {0:>7.2%}'.format(wholeScore))
+ pywikibot.output('Top left of image {0:>7.2%}'.format(topleftScore))
+ pywikibot.output('Top right of image {0:>7.2%}'.format(toprightScore))
+ pywikibot.output('Bottom left of image {0:>7.2%}'.format(bottomleftScore))
+ pywikibot.output('Bottom right of image
{0:>7.2%}'.format(bottomrightScore))
+ pywikibot.output('Center of image {0:>7.2%}'.format(centerScore))
+ pywikibot.output(' -------')
+ pywikibot.output('Average {0:>7.2%}'.format(averageScore))
# Hard coded at 80%, change this later on.
if averageScore > 0.8:
- print (u'We have a match!')
+ pywikibot.output('We have a match!')
return True
else:
- print (u'Not the same.')
+ pywikibot.output('Not the same.')
return False
@@ -133,7 +133,7 @@
if totalPixels == 0:
return 0
- return totalMatch / totalPixels * 100
+ return totalMatch / totalPixels
def main(*args):
diff --git a/scripts/upload.py b/scripts/upload.py
index e3daa44..b02068b 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -57,6 +57,7 @@
if sys.version_info[0] > 2:
from urllib.parse import urlparse
from urllib.request import URLopener
+ basestring = (str,)
else:
from urlparse import urlparse
from urllib import URLopener
--
To view, visit https://gerrit.wikimedia.org/r/184781
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I95ed0de30d2993d41a70c9b47b76c6461f40e8a0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits