[gnome-clocks] Port to python 3.



commit 4a5ac0e930438551228b08782cb081d300ef02e8
Author: MaÃl Lavault <mael lavault mailz org>
Date:   Mon Dec 24 16:50:06 2012 +0100

    Port to python 3.
    
    Straight port to python3 using 2to3.

 configure.ac             |    2 +-
 gnome-clocks             |    2 +-
 gnomeclocks/__init__.py  |    2 +-
 gnomeclocks/alarm.py     |   12 ++++++------
 gnomeclocks/app.py       |   12 ++++++------
 gnomeclocks/stopwatch.py |    4 ++--
 gnomeclocks/timer.py     |    6 +++---
 gnomeclocks/utils.py     |   10 +++++-----
 gnomeclocks/widgets.py   |    2 +-
 gnomeclocks/world.py     |   10 +++++-----
 10 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 833d568..7f97ab4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,7 +10,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip foreign])
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 
-AM_PATH_PYTHON([2.7])
+AM_PATH_PYTHON([3.2])
 
 IT_PROG_INTLTOOL(0.40)
 AM_GNU_GETTEXT([external])
diff --git a/gnome-clocks b/gnome-clocks
index fd4bcb5..2440a03 100755
--- a/gnome-clocks
+++ b/gnome-clocks
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 # -.- coding: utf-8 -.-
 
 # Copyright (c) 2011-2012 Collabora, Ltd.
diff --git a/gnomeclocks/__init__.py b/gnomeclocks/__init__.py
index cdcd8bc..88ffd83 100644
--- a/gnomeclocks/__init__.py
+++ b/gnomeclocks/__init__.py
@@ -20,7 +20,7 @@
 
 import locale
 import gettext
-from defs import *
+from .defs import *
 
 
 # Setup i18n support
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index a1967c6..6211929 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -21,9 +21,9 @@ import errno
 import json
 from datetime import timedelta
 from gi.repository import GLib, GObject, Gtk
-from clocks import Clock
-from utils import Alert, Dirs, LocalizedWeekdays, SystemSettings, TimeString, WallClock
-from widgets import Toolbar, ToolButton, SymbolicToolButton, SelectableIconView, ContentView
+from .clocks import Clock
+from .utils import Alert, Dirs, LocalizedWeekdays, SystemSettings, TimeString, WallClock
+from .widgets import Toolbar, ToolButton, SymbolicToolButton, SelectableIconView, ContentView
 
 
 wallclock = WallClock.get_default()
@@ -44,13 +44,13 @@ class AlarmsStorage:
                 "active": a.active
             }
             alarm_list.append(d)
-        with open(self.filename, "wb") as f:
+        with open(self.filename, 'w', encoding='utf-8') as f:
             json.dump(alarm_list, f, ensure_ascii=False)
 
     def load(self):
         alarms = []
         try:
-            with open(self.filename, "rb") as f:
+            with open(self.filename, encoding='utf-8') as f:
                 alarm_list = json.load(f)
             for a in alarm_list:
                 try:
@@ -60,7 +60,7 @@ class AlarmsStorage:
                 except:
                     # skip alarms which do not have the required fields
                     continue
-                alarm = AlarmItem(n.encode("utf-8"), h, m, d, active)
+                alarm = AlarmItem(n, h, m, d, active)
                 alarms.append(alarm)
         except IOError as e:
             if e.errno == errno.ENOENT:
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index 9958608..1d8e6e8 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -19,12 +19,12 @@
 import os
 import sys
 from gi.repository import Gtk, Gdk, Gio, GtkClutter
-from world import World
-from alarm import Alarm
-from stopwatch import Stopwatch
-from timer import Timer
-from widgets import Toolbar, Embed
-from utils import Dirs
+from .world import World
+from .alarm import Alarm
+from .stopwatch import Stopwatch
+from .timer import Timer
+from .widgets import Toolbar, Embed
+from .utils import Dirs
 from gnomeclocks import VERSION, AUTHORS, COPYRIGHTS, LICENSE
 
 
diff --git a/gnomeclocks/stopwatch.py b/gnomeclocks/stopwatch.py
index d08395a..34bd675 100644
--- a/gnomeclocks/stopwatch.py
+++ b/gnomeclocks/stopwatch.py
@@ -18,8 +18,8 @@
 
 import time
 from gi.repository import GLib, Gtk
-from clocks import Clock
-from widgets import Toolbar
+from .clocks import Clock
+from .widgets import Toolbar
 
 
 class Stopwatch(Clock):
diff --git a/gnomeclocks/timer.py b/gnomeclocks/timer.py
index add002c..0fd57a6 100644
--- a/gnomeclocks/timer.py
+++ b/gnomeclocks/timer.py
@@ -19,9 +19,9 @@
 import time
 import math
 from gi.repository import GLib,  GObject, Gtk
-from clocks import Clock
-from utils import Alert
-from widgets import Spinner, Toolbar
+from .clocks import Clock
+from .utils import Alert
+from .widgets import Spinner, Toolbar
 
 
 class TimerScreen(Gtk.Grid):
diff --git a/gnomeclocks/utils.py b/gnomeclocks/utils.py
index 41cce68..d68fe33 100644
--- a/gnomeclocks/utils.py
+++ b/gnomeclocks/utils.py
@@ -19,10 +19,10 @@
 import os
 import time
 import datetime
-import pycanberra
-from gnomeclocks import GNOMECLOCKS_DATADIR
 from xdg import BaseDirectory
 from gi.repository import GObject, Gio, GnomeDesktop, Notify
+from . import pycanberra
+from gnomeclocks import GNOMECLOCKS_DATADIR
 
 
 def N_(message):
@@ -31,7 +31,7 @@ def N_(message):
 
 class Dirs:
     if os.path.exists(os.path.join("gnome-clocks.doap")):
-        print "Running from a source checkout, loading local data"
+        print("Running from a source checkout, loading local data")
         datadir = os.path.join("data")
     else:
         datadir = GNOMECLOCKS_DATADIR
@@ -167,7 +167,7 @@ class Alert:
         try:
             self.canberra = pycanberra.Canberra()
         except Exception as e:
-            print "Sound will not be available: ", e
+            print("Sound will not be available: ", e)
             self.canberra = None
 
         self.soundtheme = Alert.settings.get_string('theme-name')
@@ -178,7 +178,7 @@ class Alert:
             self.notification = Notify.Notification.new(title, msg, "gnome-clocks")
             self.notification.set_hint_string("desktop-entry", "gnome-clocks")
         else:
-            print "Error: Could not trigger Alert"
+            print("Error: Could not trigger Alert")
 
     def show(self):
         if self.canberra:
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index cfc12df..a7c3327 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -206,7 +206,7 @@ class Spinner(Gtk.SpinButton):
         self.set_increments(1.0, 1.0)
         self.set_wrap(True)
         self.set_range(min_value, max_value)
-        attrs = Pango.parse_markup('<span font_desc=\"64.0\">00</span>', -1, u'\x00')[1]
+        attrs = Pango.parse_markup('<span font_desc=\"64.0\">00</span>', -1, '\x00')[1]
         self.set_attributes(attrs)
 
         self.connect('output', self._show_leading_zeros)
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index 11dfbca..6cb9fc4 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -22,9 +22,9 @@ import time
 import json
 from gi.repository import GLib, Gio, GdkPixbuf, Gtk
 from gi.repository import GWeather
-from clocks import Clock
-from utils import Dirs, TimeString, WallClock
-from widgets import Toolbar, ToolButton, SymbolicToolButton, SelectableIconView, ContentView
+from .clocks import Clock
+from .utils import Dirs, TimeString, WallClock
+from .widgets import Toolbar, ToolButton, SymbolicToolButton, SelectableIconView, ContentView
 
 
 # keep the GWeather world around as a singletom, otherwise
@@ -39,13 +39,13 @@ class WorldClockStorage:
 
     def save(self, clocks):
         locations = [str(c.location.serialize()) for c in clocks]
-        with open(self.filename, "wb") as f:
+        with open(self.filename, 'w', encoding='utf-8') as f:
             json.dump(locations, f, ensure_ascii=False)
 
     def load(self):
         clocks = []
         try:
-            with open(self.filename, "rb") as f:
+            with open(self.filename, encoding='utf-8') as f:
                 locations = json.load(f)
             for l in locations:
                 try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]