Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions/cpsection/datetime/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/cpsection/datetime/model.py')
-rw-r--r--extensions/cpsection/datetime/model.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/extensions/cpsection/datetime/model.py b/extensions/cpsection/datetime/model.py
index 76064e4..84e1259 100644
--- a/extensions/cpsection/datetime/model.py
+++ b/extensions/cpsection/datetime/model.py
@@ -26,18 +26,20 @@ import gconf
_zone_tab = '/usr/share/zoneinfo/zone.tab'
+
def _initialize():
- '''Initialize the docstring of the set function'''
+ """Initialize the docstring of the set function"""
if set_timezone.__doc__ is None:
# when running under 'python -OO', all __doc__ fields are None,
# so += would fail -- and this function would be unnecessary anyway.
return
- timezones = read_all_timezones()
+ timezones = read_all_timezones()
for timezone in timezones:
- set_timezone.__doc__ += timezone + '\n'
-
+ set_timezone.__doc__ += timezone + '\n'
+
+
def read_all_timezones(fn=_zone_tab):
- fd = open (fn, 'r')
+ fd = open(fn, 'r')
lines = fd.readlines()
fd.close()
timezones = []
@@ -48,7 +50,7 @@ def read_all_timezones(fn=_zone_tab):
if len(line) > 1:
timezones.append(line[2])
timezones.sort()
-
+
for offset in xrange(-12, 13):
if offset < 0:
tz = 'GMT%d' % offset
@@ -56,7 +58,7 @@ def read_all_timezones(fn=_zone_tab):
tz = 'GMT+%d' % offset
else:
tz = 'GMT'
- timezones.append(tz)
+ timezones.append(tz)
for offset in xrange(-12, 13):
if offset < 0:
tz = 'UTC%d' % offset
@@ -64,16 +66,19 @@ def read_all_timezones(fn=_zone_tab):
tz = 'UTC+%d' % offset
else:
tz = 'UTC'
- timezones.append(tz)
+ timezones.append(tz)
return timezones
+
def get_timezone():
client = gconf.client_get_default()
return client.get_string('/desktop/sugar/date/timezone')
+
def print_timezone():
print get_timezone()
+
def set_timezone(timezone):
"""Set the system timezone
timezone : e.g. 'America/Los_Angeles'
@@ -84,9 +89,8 @@ def set_timezone(timezone):
client = gconf.client_get_default()
client.set_string('/desktop/sugar/date/timezone', timezone)
else:
- raise ValueError(_("Error timezone does not exist."))
+ raise ValueError(_('Error timezone does not exist.'))
return 1
-# inilialize the docstrings for the timezone
+# inilialize the docstrings for the timezone
_initialize()
-