Merge lp:~kolmis/wxbanker/xdg-base-dir into lp:wxbanker

Proposed by Michael Rooney
Status: Merged
Merged at revision: not available
Proposed branch: lp:~kolmis/wxbanker/xdg-base-dir
Merge into: lp:wxbanker
Diff against target: None lines
To merge this branch: bzr merge lp:~kolmis/wxbanker/xdg-base-dir
Reviewer Review Type Date Requested Status
Michael Rooney Approve
Review via email: mp+10008@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Rooney (mrooney) wrote :

I'll propose this for merging so I can get a nice diff and start testing it. Any important things to know? Is it functional from your understanding?

Revision history for this message
Michael Rooney (mrooney) wrote :

Excellent, this looks pretty good so I'm merging it into trunk. It doesn't actually comply with XDG but it lays the important ground work to do so; I'll implement the stub data and config methods in trunk. Thanks for this branch, it is much appreciated!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accountlistctrl.py'
2--- accountlistctrl.py 2009-04-22 01:48:05 +0000
3+++ accountlistctrl.py 2009-04-28 21:09:07 +0000
4@@ -439,7 +439,7 @@
5 def onRemoveButton(self, event):
6 if self.currentIndex is not None:
7 account = self.accountObjects[self.currentIndex]
8- warningMsg = _("This will permanently remove the account '%s' and all its transactions. Continue?").decode("utf-8")
9+ warningMsg = _("This will permanently remove the account '%s' and all its transactions. Continue?")
10 dlg = wx.MessageDialog(self, warningMsg%account.Name, _("Warning"), style=wx.YES_NO|wx.ICON_EXCLAMATION)
11 if dlg.ShowModal() == wx.ID_YES:
12 # Remove the account from the model.
13
14=== modified file 'controller.py'
15--- controller.py 2009-04-08 02:30:18 +0000
16+++ controller.py 2009-05-03 07:50:49 +0000
17@@ -215,7 +215,8 @@
18 """
19
20 from persistentstore import PersistentStore
21-import wx, os, sys
22+import wx
23+import fileservice as fs
24 from wx.lib.pubsub import Publisher
25 import debug
26
27@@ -225,8 +226,8 @@
28 self._AutoSave = autoSave
29 self.Models = []
30
31+ self.InitConfig()
32 self.LoadPath(path, use=True)
33- self.InitConfig()
34
35 Publisher.subscribe(self.onAutoSaveToggled, "user.autosave_toggled")
36 Publisher.subscribe(self.onSaveRequest, "user.saved")
37@@ -237,9 +238,9 @@
38 # have which differ from the default values of the types,
39 # so initializing an Int to 0 or a Bool to False is not needed.
40 self.wxApp = wx.App(False)
41+ self.wxApp.SetAppName("wxBanker")
42 self.wxApp.Controller = self
43-
44- config = wx.Config("wxBanker")
45+ config = wx.Config(localFilename=fs.getConfigFilePath('wxBanker.cfg'))
46 wx.Config.Set(config)
47 if not config.HasEntry("SIZE_X"):
48 config.WriteInt("SIZE_X", 800)
49@@ -279,18 +280,7 @@
50
51 def LoadPath(self, path, use=False):
52 if path is None:
53- # Figure out where the bank database file is, and load it.
54- #Note: look at wx.StandardPaths.Get().GetUserDataDir() in the future
55- path = os.path.join(os.path.dirname(__file__), 'bank.db')
56- if not '--use-local' in sys.argv and 'HOME' in os.environ:
57- # We seem to be on a Unix environment.
58- preferredPath = os.path.join(os.environ['HOME'], '.wxbanker', 'bank.db')
59- if os.path.exists(preferredPath) or not os.path.exists(path):
60- path = preferredPath
61- # Ensure that the directory exists.
62- dirName = os.path.dirname(path)
63- if not os.path.exists(dirName):
64- os.mkdir(dirName)
65+ path=fs.getDataFilePath('bank.db')
66
67 store = PersistentStore(path)
68 store.AutoSave = self.AutoSave
69
70=== modified file 'csvimporter.py'
71--- csvimporter.py 2009-03-26 06:09:15 +0000
72+++ csvimporter.py 2009-05-02 22:16:05 +0000
73@@ -5,6 +5,7 @@
74 from bankobjects import Transaction
75 from wx.lib.pubsub import Publisher
76 import codecs, csv, os, re
77+import fileservice as fs
78 try:
79 import simplejson as json
80 except:
81@@ -57,21 +58,7 @@
82 class CsvImporterProfileManager:
83
84 def __init__(self):
85- configFile = 'csvImportProfiles.json'
86-
87- # copied from wxbanker.py
88- defaultPath = os.path.join(os.path.dirname(__file__), configFile)
89- if 'HOME' in os.environ:
90- # We seem to be on a Unix environment.
91- preferredPath = os.path.join(os.environ['HOME'], '.config', 'wxBanker', configFile)
92- if os.path.exists(preferredPath) or not os.path.exists(defaultPath):
93- defaultPath = preferredPath
94- # Ensure that the directory exists.
95- dirName = os.path.dirname(defaultPath)
96- if not os.path.exists(dirName):
97- os.mkdir(dirName)
98-
99- self.configFile = defaultPath
100+ self.configFile = fs.getConfigFilePath('csvImportProfiles.json')
101 self.loadProfiles()
102
103 def getProfile(self, key):
104
105=== added file 'fileservice.py'
106--- fileservice.py 1970-01-01 00:00:00 +0000
107+++ fileservice.py 2009-05-02 22:32:49 +0000
108@@ -0,0 +1,44 @@
109+#!/usr/bin/env python
110+# -*- coding: utf-8 -*-
111+# https://launchpad.net/wxbanker
112+# currencies.py: Copyright 2007-2009 Mike Rooney <mrooney@ubuntu.com>
113+#
114+# This file is part of wxBanker.
115+#
116+# wxBanker is free software: you can redistribute it and/or modify
117+# it under the terms of the GNU General Public License as published by
118+# the Free Software Foundation, either version 3 of the License, or
119+# (at your option) any later version.
120+#
121+# wxBanker is distributed in the hope that it will be useful,
122+# but WITHOUT ANY WARRANTY; without even the implied warranty of
123+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124+# GNU General Public License for more details.
125+#
126+# You should have received a copy of the GNU General Public License
127+# along with wxBanker. If not, see <http://www.gnu.org/licenses/>.%
128+
129+import os, sys
130+
131+def __getFilePath(filename):
132+ # Figure out where the bank database file is, and load it.
133+ #Note: look at wx.StandardPaths.Get().GetUserDataDir() in the future
134+ path = os.path.join(os.path.dirname(__file__), filename)
135+ if not '--use-local' in sys.argv and 'HOME' in os.environ:
136+ # We seem to be on a Unix environment.
137+ preferredPath = os.path.join(os.environ['HOME'], '.wxbanker', filename)
138+ if os.path.exists(preferredPath) or not os.path.exists(path):
139+ path = preferredPath
140+ # Ensure that the directory exists.
141+ dirName = os.path.dirname(path)
142+ if not os.path.exists(dirName):
143+ os.mkdir(dirName)
144+ return path
145+
146+
147+def getDataFilePath(filename):
148+ return __getFilePath(filename)
149+
150+def getConfigFilePath(filename):
151+ return __getFilePath(filename)
152+
153
154=== modified file 'localization.py'
155--- localization.py 2009-04-08 02:30:18 +0000
156+++ localization.py 2009-04-28 21:09:07 +0000
157@@ -33,7 +33,7 @@
158
159 # Install gettext.
160 import gettext
161-gettext.install(APP, DIR)
162+gettext.install(APP, DIR, unicode=True)
163
164 # Check if the user forced a language with --lang=XX.
165 import sys

Subscribers

People subscribed via source and target branches

to all changes: