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

Change subject: [IMPROV] version: Import at top and BytesIO
......................................................................


[IMPROV] version: Import at top and BytesIO

This moves the imports at the top of the file as suggested by PEP8. It
also uses BytesIO and not StringIO and delegates the decoding to the
underlying XML parser who can interpret the the header to determine the
encoding.

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

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



diff --git a/pywikibot/version.py b/pywikibot/version.py
index 8de383e..6022dff 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -18,6 +18,9 @@
 import datetime
 import subprocess
 import codecs
+import xml.dom.minidom
+
+from io import BytesIO
 
 from warnings import warn
 
@@ -182,8 +185,6 @@
     @return: the git hash
     @rtype: str
     """
-    from io import StringIO
-    import xml.dom.minidom
     from pywikibot.comms import http
 
     uri = 'https://github.com/wikimedia/%s/!svn/vcc/default' % tag
@@ -192,9 +193,8 @@
                               "<propfind xmlns=\"DAV:\"><allprop/></propfind>",
                          headers={'label': str(rev),
                                   'user-agent': 'SVN/1.7.5 {pwb}'})
-    data = request.content
 
-    dom = xml.dom.minidom.parse(StringIO(data))
+    dom = xml.dom.minidom.parse(BytesIO(request.raw))
     hsh = dom.getElementsByTagName("C:git-commit")[0].firstChild.nodeValue
     date = dom.getElementsByTagName("S:date")[0].firstChild.nodeValue
     date = time.strptime(date[:19], '%Y-%m-%dT%H:%M:%S')

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib7779b8d26a62dd11f3fcf344ca400239dbbf3f5
Gerrit-PatchSet: 3
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: 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