[gnome-clocks] Save ics file in xdg dir
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Save ics file in xdg dir
- Date: Sun, 19 Aug 2012 16:52:07 +0000 (UTC)
commit cc1a3b3308311a8e68e5fd0bdbfafc4b16d7756e
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Aug 19 18:50:42 2012 +0200
Save ics file in xdg dir
gnomeclocks/alarm.py | 6 +++---
gnomeclocks/storage.py | 11 +++++------
gnomeclocks/utils.py | 5 +++++
3 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index 6e3147a..5311618 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -20,11 +20,11 @@ import os
from datetime import datetime
import vobject
-from utils import SystemSettings
+from utils import Dirs, SystemSettings
class ICSHandler():
def __init__(self):
- self.ics_file = 'alarms.ics'
+ self.ics_file = os.path.join(Dirs.get_user_data_dir(), "alarms.ics")
def add_vevent(self, vobj):
with open(self.ics_file, 'r+') as ics:
@@ -47,7 +47,7 @@ class ICSHandler():
def generate_ics_file(self):
vcal = vobject.iCalendar()
- ics = open('alarms.ics', 'w')
+ ics = open(self.ics_file, 'w')
ics.write(vcal.serialize())
ics.close()
diff --git a/gnomeclocks/storage.py b/gnomeclocks/storage.py
index b33ad61..fb18ce0 100644
--- a/gnomeclocks/storage.py
+++ b/gnomeclocks/storage.py
@@ -16,13 +16,11 @@
#
# Author: Seif Lotfy <seif lotfy collabora co uk>
+import os
import errno
import pickle
-from xdg import BaseDirectory
from gi.repository import GWeather
-
-
-DATA_PATH = BaseDirectory.save_data_path("clocks") + "/clocks"
+from utils import Dirs
class Location():
@@ -41,6 +39,7 @@ class Location():
class WorldClockStorage():
def __init__(self):
+ self.filename = os.path.join(Dirs.get_user_data_dir(), "clocks")
world = GWeather.Location.new_world(True)
self.searchEntry = GWeather.LocationEntry.new(world)
self.searchEntry.show_all()
@@ -51,14 +50,14 @@ class WorldClockStorage():
self.locations_dump = locations = "|".join(
[location.id +\
"---" + location.location.get_code() for location in locations])
- f = open(DATA_PATH, "wb")
+ f = open(self.filename, "wb")
pickle.dump(locations, f)
f.close()
def load_clocks(self):
clocks = []
try:
- f = open(DATA_PATH, "rb")
+ f = open(self.filename, "rb")
self.locations_dump = locations = pickle.load(f)
f.close()
locations = locations.split("|")
diff --git a/gnomeclocks/utils.py b/gnomeclocks/utils.py
index d68ed43..d27db81 100644
--- a/gnomeclocks/utils.py
+++ b/gnomeclocks/utils.py
@@ -17,6 +17,8 @@
# Author: Seif Lotfy <seif lotfy collabora co uk>
import os
+
+from xdg import BaseDirectory
from gi.repository import Gio, Gst, Notify
class Dirs:
@@ -44,6 +46,9 @@ class Dirs:
path = "locale"
return path
+ @staticmethod
+ def get_user_data_dir():
+ return BaseDirectory.save_data_path("gnome-clocks")
class SystemSettings:
@staticmethod
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]