Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [d88aab3981]

Overview
Comment:Wrap `gzip_decode` as fallback for Python 2.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d88aab39812eb65a8528ee67503d5f5dfd47aae1
User & Date: mario on 2015-04-05 14:09:09
Other Links: manifest | tags
Context
2015-04-05
14:09
Update window title for currently selected category tab. check-in: a6f5f66365 user: mario tags: trunk
14:09
Wrap `gzip_decode` as fallback for Python 2. check-in: d88aab3981 user: mario tags: trunk
14:08
Manually register addon widget signals. Otherwise main keeps bugging with GtkWarnings when timer plugin is disabled. check-in: 33e106bce5 user: mario tags: trunk
Changes

Modified compat2and3.py from [26cc8f6b71] to [e41c080b1a].

1
2
3
4
5

6
7
8
9
10
11
12
1
2
3
4

5
6
7
8
9
10
11
12




-
+







# encoding: UTF-8
# api: python 
# type: functions
# title: Python2 and Python3 compatibility
# version: 0.1
# version: 0.2
#
# Renames some Python3 modules into their Py2 equivalent.
# Slim local alternative to `six` module.


import sys

28
29
30
31
32
33
34




35
36
37
38
39
40
41
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+
+
+
+







    import urllib2
    from urllib import urlencode
    import urlparse
    import cookielib
    
    # filesys
    from StringIO import StringIO
    from gzip import GzipFile
    def gzip_decode(bytes):
        return GzipFile(fileobj=StringIO(bytes)).read()
        # return zlib.decompress(bytes, 16 + zlib.MAX_WBITS)    # not fully compatible


# Python 3
else:

    # version tags
    PY2 = 0
50
51
52
53
54
55
56

57
58











54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74







+


+
+
+
+
+
+
+
+
+
+
+
    import urllib.request as urllib2
    from urllib.parse import urlencode
    import urllib.parse as urlparse
    from http import cookiejar as cookielib
    
    # filesys
    from io import StringIO
    from gzip import decompress as gzip_decode

    
# Both

# find_executable() is only needed by channels/configwin
try:
    from distutils.spawn import find_executable
except:
    def find_executable(bin):
        exists = [os.path.exists(dir+"/"+bin) for dir in os.environ.get("PATH").split(":")+["/"]]
        return exists[0] if len(exists) else None

    

Modified config.py from [86c0092432] to [8430e295e9].

22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
22
23
24
25
26
27
28
29
30
31
32
33









34
35
36
37
38
39
40







+




-
-
-
-
-
-
-
-
-








import os
import sys
import json
import gzip
import platform
import re
from compat2and3 import gzip_decode, find_executable
import zlib
import zipfile
import inspect
import pkgutil

# find_executable() is only needed by channels/configwin
try:
    from distutils.spawn import find_executable
except:
    def find_executable(bin):
        exists = [os.path.exists(dir+"/"+bin) for dir in os.environ.get("PATH").split(":")+["/"]]
        return exists[0] if len(exists) else None


# export symbols
__all__ = ["conf", "__print__", "dbg", "plugin_meta", "module_list", "get_data", "find_executable"]


#-- create a stub instance of config object
conf = object()
258
259
260
261
262
263
264
265

266
267
268
269


270
271
272
273
274
275
276
250
251
252
253
254
255
256

257
258
259


260
261
262
263
264
265
266
267
268







-
+


-
-
+
+







            if server in netrc:
                return netrc[server]
        


# Retrieve content from install path or pyzip archive (alias for pkgutil.get_data)
#
def get_data(fn, decode=False, z=False, file_base="config"):
def get_data(fn, decode=False, gz=False, file_base="config"):
    try:
        bin = pkgutil.get_data(file_base, fn)
        if z:
            bin = zlib.decompress(bin)
        if gz:
            bin = gzip_decode(bin)
        if decode:
            return bin.decode("utf-8")
        else:
            return str(bin)
    except:
        pass