Check-in [0458e0e0d1]
Overview
Comment: | Add unicode() vs str() to compat2and3 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | py3 |
Files: | files | file ages | folders |
SHA1: |
0458e0e0d165243533e49d86ac68b636 |
User & Date: | mario on 2014-04-08 22:16:26 |
Other Links: | branch diff | manifest | tags |
Context
2014-04-09
| ||
00:23 | Temporary fix for Gtk undefined color warnings, workaround for changed GtkMenu.popup() signature in Gtk3. Debug colors for mygtk.columns() creation. check-in: 489da08a74 user: mario tags: py3 | |
2014-04-08
| ||
22:16 | Add unicode() vs str() to compat2and3 check-in: 0458e0e0d1 user: mario tags: py3 | |
21:53 | fix dict + dict back into list join check-in: d09e020ecf user: mario tags: py3 | |
Changes
Modified compat2and3.py from [022ad69c97] to [13b56cb24d].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # version tags PY2 = 1 PY3 = 0 # basic functions xrange = xrange range = xrange # urllib modules import urllib import urllib2 from urllib import urlencode import urlparse import cookielib | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # version tags PY2 = 1 PY3 = 0 # basic functions xrange = xrange range = xrange unicode = unicode # urllib modules import urllib import urllib2 from urllib import urlencode import urlparse import cookielib |
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # version tags PY2 = 0 PY3 = 1 # basic functions xrange = range # urllib modules import urllib.request as urllib 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 | > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # version tags PY2 = 0 PY3 = 1 # basic functions xrange = range unicode = str # urllib modules import urllib.request as urllib 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 |
Modified help/streamtuner2.1 from [de31364a43] to [ca2f8a1565].
|
| < | 1 2 3 4 5 6 7 | .\" (many thanks to the manpage howto!) .\" .TH streamtuner2 "January 2014" "BSD/Linux" "User Manuals" .SH NAME streamtuner2 \- Browser for internet radio stations .SH SYNOPSIS .B streamtuner2 |
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | .BI streamtuner2 " stream" " shoutcast,xiph" " ""Top 100""" Searches for the term "Top 100" in the shoutcast and xiph channels, and returns all info about the first match as JSON output. .TP .BI streamtuner2 " play frequence3" Looks for the first occourence, and starts the audio player for FREQUENCE3. .SH FILES .IR /home/ $USER /.config/streamtuner2/settings.json .SH "SEE ALSO" .BR streamripper (1) .BR audacious (1) .BR json (5) .BR m3u (5) .BR pls (5) | > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | .BI streamtuner2 " stream" " shoutcast,xiph" " ""Top 100""" Searches for the term "Top 100" in the shoutcast and xiph channels, and returns all info about the first match as JSON output. .TP .BI streamtuner2 " play frequence3" Looks for the first occourence, and starts the audio player for FREQUENCE3. .SH GRAPHICAL MODE There's only one option for the graphical UI mode: .TP .BI --gtk3 Loads Gtk3 via PyGI instead of Gtk2. This is implicit when running on Python3 anyway. .SH FILES .IR /home/ $USER /.config/streamtuner2/settings.json .SH "SEE ALSO" .BR streamripper (1) .BR audacious (1) .BR json (5) .BR m3u (5) .BR pls (5) |
Modified mygtk.py from [91f32ed114] to [3b0c65b63e].
︙ | ︙ | |||
30 31 32 33 34 35 36 | from config import __print__, dbg # filesystem import os.path import copy import sys | < | | | > | < < > | < < < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | from config import __print__, dbg # filesystem import os.path import copy import sys from compat2and3 import unicode, xrange, PY3 # gtk version (2=gtk2, 3=gtk3) ver = 2 # if running on Python3 or with commandline flag if PY3 or "--gtk3" in sys.argv: ver = 3 # load gtk modules if ver==3: from gi import pygtkcompat as pygtk pygtk.enable() pygtk.enable_gtk(version='3.0') from gi.repository import Gtk as gtk from gi.repository import GObject as gobject from gi.repository import GdkPixbuf ui_file = "gtk3.xml" empty_pixbuf = GdkPixbuf.Pixbuf.new_from_data(b"\0\0\0\0", GdkPixbuf.Colorspace.RGB, True, 8, 1, 1, 4, None, None) __print__(dbg.PROC, gtk) __print__(dbg.PROC, gobject) else: import pygtk import gtk import gobject ui_file = "gtk2.xml" empty_pixbuf = gtk.gdk.pixbuf_new_from_data(b"\0\0\0\0",gtk.gdk.COLORSPACE_RGB,True,8,1,1,4) # simplified gtk constructors --------------------------------------------- class mygtk: |
︙ | ︙ | |||
112 113 114 115 116 117 118 | col.set_resizable(True) # width if (desc[1] > 0): col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_fixed_width(desc[1]) # loop through cells | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | col.set_resizable(True) # width if (desc[1] > 0): col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_fixed_width(desc[1]) # loop through cells for var in xrange(2, len(desc)): cell = desc[var] # cell renderer if (cell[2] == "pixbuf"): rend = gtk.CellRendererPixbuf() # img cell if (cell[1] == str): cell[3]["stock_id"] = datapos # for stock icons expand = False |
︙ | ︙ | |||
154 155 156 157 158 159 160 | # add data? if (entries): #- expand datamap vartypes = [] #(str, str, bool, str, int, int, gtk.gdk.Pixbuf, str, int) rowmap = [] #["title", "desc", "bookmarked", "name", "count", "max", "img", ...] if (not rowmap): for desc in datamap: | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | # add data? if (entries): #- expand datamap vartypes = [] #(str, str, bool, str, int, int, gtk.gdk.Pixbuf, str, int) rowmap = [] #["title", "desc", "bookmarked", "name", "count", "max", "img", ...] if (not rowmap): for desc in datamap: for var in xrange(2, len(desc)): vartypes.append(desc[var][1]) # content types rowmap.append(desc[var][0]) # dict{} column keys in entries[] list # create gtk array storage ls = gtk.ListStore(*vartypes) # could be a TreeStore, too __print__(vartypes) __print__(rowmap) |
︙ | ︙ |
Modified pson.py from [759da668d2] to [b0e4064063].
︙ | ︙ | |||
18 19 20 21 22 23 24 | # might have been queried from the widgets. # #-- reading and writing json (for the config module) ---------------------------------- import sys | < | < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # might have been queried from the widgets. # #-- reading and writing json (for the config module) ---------------------------------- import sys from compat2and3 import unicode # try to load the system module first try: from json import dump as json_dump, load as json_load except: print("no native Python JSON module") |
︙ | ︙ |