[hamster-applet] PEPified
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Subject: [hamster-applet] PEPified
- Date: Sat, 23 May 2009 20:15:37 -0400 (EDT)
commit 6509663c18ec3c81b9641bbfdd2e284896a8fb0e
Author: Toms Bauģis <toms baugis gmail com>
Date: Sun May 24 01:00:08 2009 +0100
PEPified
---
hamster/Configuration.py => configuration.py | 0
data/applet.ui | 2 +-
hamster/KeyBinder.py | 2 +-
hamster/Makefile.am | 2 +-
hamster/applet.py | 10 ++++----
hamster/charting.py | 6 ++--
hamster/db.py | 6 ++--
hamster/graphics.py | 12 +++++-----
hamster/hamster-applet.py | 4 +-
hamster/preferences.py | 8 +++---
hamster/stats.py | 4 +-
hamster/stuff.py | 2 +-
hamster/widgets.py | 2 +-
tests/stuff_test.py | 28 +++++++++++++-------------
14 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/hamster/Configuration.py b/configuration.py
similarity index 100%
rename from hamster/Configuration.py
rename to configuration.py
diff --git a/data/applet.ui b/data/applet.ui
index d9ebee0..688bbc4 100644
--- a/data/applet.ui
+++ b/data/applet.ui
@@ -90,7 +90,7 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0.50999999046325684</property>
- <property name="label" translatable="yes"><span size="small" >Type in activity and hit Enter to start tracking!</span></property>
+ <property name="label" translatable="yes"><span size="small" >Type in an activity and hit Enter to start tracking!</span></property>
<property name="use_markup">True</property>
</object>
<packing>
diff --git a/hamster/KeyBinder.py b/hamster/KeyBinder.py
index 515cec1..9372a8c 100644
--- a/hamster/KeyBinder.py
+++ b/hamster/KeyBinder.py
@@ -32,7 +32,7 @@ class Keybinder(object):
self.prevbinding = None
self.key_combination = self.config.get_keybinding()
- if self.key_combination == None:
+ if self.key_combination is None:
# This is for uninstalled cases, the real default is in the schema
self.key_combination = "<Super>H"
diff --git a/hamster/Makefile.am b/hamster/Makefile.am
index 0582f10..28e753d 100644
--- a/hamster/Makefile.am
+++ b/hamster/Makefile.am
@@ -22,7 +22,7 @@ hamster_PYTHON = \
charting.py \
widgets.py \
graphics.py \
- Configuration.py \
+ configuration.py \
KeyBinder.py \
preferences.py \
stuff.py \
diff --git a/hamster/applet.py b/hamster/applet.py
index 94119f5..d55e827 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -36,7 +36,7 @@ import dbus.mainloop.glib
from hamster import dispatcher, storage, SHARED_DATA_DIR
import hamster.eds
-from hamster.Configuration import GconfStore
+from hamster.configuration import GconfStore
from hamster import stuff
from hamster.KeyBinder import *
@@ -509,7 +509,7 @@ Now, start tracking!
"""refresh hamster every x secs - load today, check last activity etc."""
# stop tracking task if computer is idle for X minutes
if self.timeout_enabled and self.last_activity and \
- self.last_activity['end_time'] == None:
+ self.last_activity['end_time'] is None:
if self.dbusIdleListener.is_idle:
# Only subtract idle time from the running task when
# idleness is due to time out, not a screen lock.
@@ -531,7 +531,7 @@ Now, start tracking!
return True
def update_label(self):
- if self.last_activity and self.last_activity['end_time'] == None:
+ if self.last_activity and self.last_activity['end_time'] is None:
delta = datetime.datetime.now() - self.last_activity['start_time']
duration = delta.seconds / 60
label = "%s %s" % (self.last_activity['name'],
@@ -698,7 +698,7 @@ Now, start tracking!
def __update_fact(self):
"""dbus controller current fact updating"""
- if self.last_activity and self.last_activity['end_time'] == None:
+ if self.last_activity and self.last_activity['end_time'] is None:
self.dbusController.update_fact(self.last_activity["name"])
else:
self.dbusController.update_fact(_(u'No activity'))
@@ -708,7 +708,7 @@ Now, start tracking!
"""main window display and positioning"""
self.button.set_active(is_active)
- if self.last_activity and self.last_activity["end_time"] == None:
+ if self.last_activity and self.last_activity["end_time"] is None:
label = self.last_activity['name']
if self.last_activity['category'] != _("Unsorted"):
label += "@%s" % self.last_activity['category']
diff --git a/hamster/charting.py b/hamster/charting.py
index a5bed7a..3b8e345 100644
--- a/hamster/charting.py
+++ b/hamster/charting.py
@@ -95,7 +95,7 @@ def size_list(set, target_set):
#nest
for i in range(len(set)):
- if type(set[i]) == list:
+ if isinstance(set[i], list):
set[i] = size_list(set[i], target_set[i])
return set
@@ -287,7 +287,7 @@ class Chart(graphics.Area):
else:
def finish_all(integrators):
for i in range(len(integrators)):
- if type(integrators[i]) == list:
+ if isinstance(integrators[i], list):
finish_all(integrators[i])
else:
integrators[i].finish()
@@ -343,7 +343,7 @@ class Chart(graphics.Area):
#need function to go recursive
def retarget(integrators, new_values):
for i in range(len(new_values)):
- if type(new_values[i]) == list:
+ if isinstance(new_values[i], list):
integrators[i] = retarget(integrators[i], new_values[i])
else:
if isinstance(integrators[i], graphics.Integrator) == False:
diff --git a/hamster/db.py b/hamster/db.py
index 7201287..b430894 100644
--- a/hamster/db.py
+++ b/hamster/db.py
@@ -607,7 +607,7 @@ class Storage(hamster.storage.Storage):
""" Here be dragons (lame connection/cursor wrappers) """
def get_connection(self):
- if self.con == None:
+ if self.con is None:
self.con = sqlite.connect(hamster.HAMSTER_DB, detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
self.con.row_factory = sqlite.Row
@@ -645,11 +645,11 @@ class Storage(hamster.storage.Storage):
con = self.connection
cur = con.cursor()
- if type(statement) != list: #we kind of think that we will get list of instructions
+ if isinstance(statement, list) == False: #we kind of think that we will get list of instructions
statement = [statement]
params = [params]
- if type(statement) == list:
+ if isinstance(statement, list):
for i in range(len(statement)):
if hamster.trace_sql:
print statement[i], params[i]
diff --git a/hamster/graphics.py b/hamster/graphics.py
index 08e79d7..805aebb 100644
--- a/hamster/graphics.py
+++ b/hamster/graphics.py
@@ -110,7 +110,7 @@ class Area(gtk.DrawingArea):
x_value = self.value_boundaries[0] + x_value * x_factor
else: #case when min is larger than max (flipped)
x_value = self.value_boundaries[1] - x_value * x_factor
- if y_value == None:
+ if y_value is None:
return x_value + self.graph_x
if y_value != None:
@@ -119,7 +119,7 @@ class Area(gtk.DrawingArea):
y_value = self.value_boundaries[2] + y_value * y_factor
else: #case when min is larger than max (flipped)
y_value = self.value_boundaries[2] - y_value * y_factor
- if x_value == None:
+ if x_value is None:
return y_value + self.graph_y
return x_value + self.graph_x, y_value + self.graph_y
@@ -130,11 +130,11 @@ class Area(gtk.DrawingArea):
if x != None:
x = (x - self.graph_x) / x_factor
- if y == None:
+ if y is None:
return x
if y != None:
y = (y - self.graph_x) / y_factor
- if x == None:
+ if x is None:
return y
return x, y
@@ -168,7 +168,7 @@ class Integrator(object):
def __init__(self, start_value, damping = 0.5, attraction = 0.2):
#if we got datetime, convert it to unix time, so we operate with numbers again
self.current_value = start_value
- if type(start_value) == dt.datetime:
+ if isinstance(start_value, dt.datetime):
self.current_value = int(time.mktime(start_value.timetuple()))
self.value_type = type(start_value)
@@ -193,7 +193,7 @@ class Integrator(object):
"""target next value"""
self.targeting = True
self.target_value = value
- if type(value) == dt.datetime:
+ if isinstance(value, dt.datetime):
self.target_value = int(time.mktime(value.timetuple()))
def update(self):
diff --git a/hamster/hamster-applet.py b/hamster/hamster-applet.py
index f74bb11..db6d621 100755
--- a/hamster/hamster-applet.py
+++ b/hamster/hamster-applet.py
@@ -59,14 +59,14 @@ def applet_factory(applet, iid):
return True
def on_destroy(event):
- from hamster.Configuration import GconfStore
+ from hamster.configuration import GconfStore
config = GconfStore.get_instance()
# handle config option to stop tracking on shutdown
if config.get_stop_on_shutdown():
from hamster import storage
last_activity = storage.get_last_activity()
- if last_activity and last_activity['end_time'] == None:
+ if last_activity and last_activity['end_time'] is None:
storage.touch_fact(last_activity)
if gtk.main_level():
diff --git a/hamster/preferences.py b/hamster/preferences.py
index c3b35c2..b0c1364 100755
--- a/hamster/preferences.py
+++ b/hamster/preferences.py
@@ -25,7 +25,7 @@ import os
import gtk
from hamster import dispatcher, storage, SHARED_DATA_DIR, stuff
-from hamster.Configuration import GconfStore
+from hamster.configuration import GconfStore
def get_prev(selection, model):
(model, iter) = selection.get_selected()
@@ -67,7 +67,7 @@ class ActivityStore(gtk.ListStore):
self.clear()
- if category_id == None:
+ if category_id is None:
return
activity_list = storage.get_activities(category_id)
@@ -353,7 +353,7 @@ class PreferencesEditor:
""" enables and disables action buttons depending on selected item """
(model, iter) = selection.get_selected()
id = 0
- if iter == None:
+ if iter is None:
self.activity_store.clear()
else:
self.prev_selected_activity = None
@@ -395,7 +395,7 @@ class PreferencesEditor:
first_item = model.get_path(iter) == (0,)
self.get_widget('activity_up').set_sensitive(not first_item)
- last_item = model.iter_next(iter) == None
+ last_item = model.iter_next(iter) is None
self.get_widget('activity_down').set_sensitive(not last_item)
def _del_selected_row(self, tree):
diff --git a/hamster/stats.py b/hamster/stats.py
index 6cf3ffa..f96077a 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -145,7 +145,7 @@ class StatsViewer(object):
def setup_tree(self):
def parent_painter(column, cell, model, iter):
cell_text = model.get_value(iter, 1)
- if model.iter_parent(iter) == None:
+ if model.iter_parent(iter) is None:
if model.get_path(iter) == (0,):
text = '<span weight="heavy">%s</span>' % cell_text
else:
@@ -167,7 +167,7 @@ class StatsViewer(object):
text = model.get_value(iter, 2)
- if model.iter_parent(iter) == None:
+ if model.iter_parent(iter) is None:
if model.get_path(iter) == (0,):
text = '<span weight="heavy">%s</span>' % text
else:
diff --git a/hamster/stuff.py b/hamster/stuff.py
index 1b26548..99bcce9 100644
--- a/hamster/stuff.py
+++ b/hamster/stuff.py
@@ -190,7 +190,7 @@ def figure_time(str_time):
if len(numbers) >= 2:
minutes = int(numbers[1])
- if (hours == None or minutes == None) or hours > 24 or minutes > 60:
+ if (hours is None or minutes is None) or hours > 24 or minutes > 60:
return None #no can do
return dt.datetime.now().replace(hour = hours, minute = minutes,
diff --git a/hamster/widgets.py b/hamster/widgets.py
index cd44294..cc3d63f 100644
--- a/hamster/widgets.py
+++ b/hamster/widgets.py
@@ -240,7 +240,7 @@ class TimeInput(gtk.Entry):
return figure_time(self.get_text())
def _format_time(self, time):
- if time == None:
+ if time is None:
return None
#return time.strftime("%I:%M%p").lstrip("0").lower()
diff --git a/tests/stuff_test.py b/tests/stuff_test.py
index f4535c1..da4e8b7 100644
--- a/tests/stuff_test.py
+++ b/tests/stuff_test.py
@@ -10,9 +10,9 @@ class TestActivityInputParsing(unittest.TestCase):
# plain activity name
activity = stuff.parse_activity_input("just a simple case")
self.assertEquals(activity.activity_name, "just a simple case")
- assert activity.category_name == None and activity.start_time == None \
- and activity.end_time == None and activity.category_name == None\
- and activity.description == None
+ assert activity.category_name is None and activity.start_time is None \
+ and activity.end_time is None and activity.category_name is None\
+ and activity.description is None
def test_with_start_time(self):
# with time
@@ -21,9 +21,9 @@ class TestActivityInputParsing(unittest.TestCase):
self.assertEquals(activity.start_time.strftime("%H:%M"), "12:35")
#rest must be empty
- assert activity.category_name == None \
- and activity.end_time == None and activity.category_name == None\
- and activity.description == None
+ assert activity.category_name is None \
+ and activity.end_time is None and activity.category_name is None\
+ and activity.description is None
def test_with_start_and_end_time(self):
# with time
@@ -33,26 +33,26 @@ class TestActivityInputParsing(unittest.TestCase):
self.assertEquals(activity.end_time.strftime("%H:%M"), "14:25")
#rest must be empty
- assert activity.category_name == None \
- and activity.category_name == None\
- and activity.description == None
+ assert activity.category_name is None \
+ and activity.category_name is None\
+ and activity.description is None
def test_category(self):
# plain activity name
activity = stuff.parse_activity_input("just a simple case hamster")
self.assertEquals(activity.activity_name, "just a simple case")
self.assertEquals(activity.category_name, "hamster")
- assert activity.start_time == None \
- and activity.end_time == None \
- and activity.description == None
+ assert activity.start_time is None \
+ and activity.end_time is None \
+ and activity.description is None
def test_description(self):
# plain activity name
activity = stuff.parse_activity_input("case, with added description")
self.assertEquals(activity.activity_name, "case")
self.assertEquals(activity.description, "with added description")
- assert activity.category_name == None and activity.start_time == None \
- and activity.end_time == None and activity.category_name == None
+ assert activity.category_name is None and activity.start_time is None \
+ and activity.end_time is None and activity.category_name is None
def test_full(self):
# plain activity name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]