jenkins-bot has submitted this change and it was merged.

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). But because
of that it does now only say two images are the same, when they are
equal to 80 % and not 0.8 %.

This also renames the job from flake83 to flake8-py3.

Change-Id: I95ed0de30d2993d41a70c9b47b76c6461f40e8a0
---
M scripts/match_images.py
M scripts/upload.py
M tox.ini
3 files changed, 15 insertions(+), 13 deletions(-)

Approvals:
  Ricordisamoa: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/match_images.py b/scripts/match_images.py
index 304583b..55076e1 100644
--- a/scripts/match_images.py
+++ b/scripts/match_images.py
@@ -87,21 +87,23 @@
     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%}\n'
+                     'Top left of image     {1:>7.2%}\n'
+                     'Top right of image    {2:>7.2%}\n'
+                     'Bottom left of image  {3:>7.2%}\n'
+                     'Bottom right of image {4:>7.2%}\n'
+                     'Center of image       {5:>7.2%}\n'
+                     '                      -------\n'
+                     'Average               {6:>7.2%}'.format(
+        wholeScore, topleftScore, toprightScore, bottomleftScore,
+        bottomrightScore, centerScore, 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 +135,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
diff --git a/tox.ini b/tox.ini
index eb8cf2c..ae60d99 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,12 +18,11 @@
 deps = flake8
        flake8-docstrings
 
-[testenv:flake83]
+[testenv:flake8-py3]
 commands = flake8 --ignore=D102,D103,E122,E127,E241 {posargs}
 basepython = python3
 deps = flake8
        flake8-docstrings
-
 
 [testenv:flake8-docstrings]
 commands = flake8 {posargs}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I95ed0de30d2993d41a70c9b47b76c6461f40e8a0
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to