Browse Source

fixes for py2 py3 compat

Thomas B 3 months ago
parent
commit
6b1c517201
2 changed files with 8 additions and 4 deletions
  1. 6
    3
      macros.py
  2. 2
    1
      poole.py

+ 6
- 3
macros.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 
2
 
3
+from __future__ import print_function
4
+
3
 import sys
5
 import sys
4
 import re
6
 import re
5
 import itertools
7
 import itertools
24
     def urlparse_foo(link):
26
     def urlparse_foo(link):
25
         return urllib.parse.parse_qs(urllib.parse.urlparse(link).query)['v'][0]
27
         return urllib.parse.parse_qs(urllib.parse.urlparse(link).query)['v'][0]
26
 else:
28
 else:
29
+    import urllib
27
     import urlparse
30
     import urlparse
28
     def urlparse_foo(link):
31
     def urlparse_foo(link):
29
         return urlparse.parse_qs(urlparse.urlparse(link).query)['v'][0]
32
         return urlparse.parse_qs(urlparse.urlparse(link).query)['v'][0]
398
         sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
401
         sys.stderr.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
399
         sys.stderr.write("\n")
402
         sys.stderr.write("\n")
400
         return ""
403
         return ""
401
-    data = json.loads(response.read())
404
+    data = json.loads(response.read().decode("utf-8"))
402
     return data
405
     return data
403
 
406
 
404
 def restReleases(user, repo):
407
 def restReleases(user, repo):
449
     response = urllib.request.urlopen(url) if PY3 else urllib.urlopen(url)
452
     response = urllib.request.urlopen(url) if PY3 else urllib.urlopen(url)
450
     if response.getcode() != 200:
453
     if response.getcode() != 200:
451
         raise Exception("invalid response code", response.getcode())
454
         raise Exception("invalid response code", response.getcode())
452
-    data = response.read()
453
-    print(data,)
455
+    data = response.read().decode("utf-8")
456
+    print(data, end="")
454
 
457
 
455
 # -----------------------------------------------------------------------------
458
 # -----------------------------------------------------------------------------
456
 # preconvert hooks
459
 # preconvert hooks

+ 2
- 1
poole.py View File

24
 # =============================================================================
24
 # =============================================================================
25
 
25
 
26
 from __future__ import with_statement
26
 from __future__ import with_statement
27
+from __future__ import print_function
27
 
28
 
28
 import codecs
29
 import codecs
29
 import glob
30
 import glob
81
             execfile(tf.name, envdic)
82
             execfile(tf.name, envdic)
82
     import imp
83
     import imp
83
     def imp_load_source(module_name, module_path):
84
     def imp_load_source(module_name, module_path):
84
-        imp.load_source(module_name, module_path)
85
+        return imp.load_source(module_name, module_path)
85
     import urlparse
86
     import urlparse
86
     def urlparse_urljoin(a, b):
87
     def urlparse_urljoin(a, b):
87
         return urlparse.urljoin(a, b)
88
         return urlparse.urljoin(a, b)

Loading…
Cancel
Save