-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtmom_fs.py
57 lines (46 loc) · 1.74 KB
/
rtmom_fs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
File system access for rtmom (caching information for offline use)
Elementary based client for "Remember the Milk" (http://www.rememberthemilk.com/) written in Python.
Copyright (C) 2010 Michael Pilgermann <kichkasch@gmx.de>
http://github.com/kichkasch/rtmom
rtmom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
rtmom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with rtmom. If not, see <http://www.gnu.org/licenses/>.
"""
import pickle
import config
class FileHandler():
"""
Implementation for File System access (cache, offline mode)
"""
def __init__(self, filename = None):
"""
Initialize variable for filename
Either from parameter given, or - if none given - from entry in config file.
"""
if filename:
self._filename = filename
else:
self._filename = config.CACHE_PATH
def loadFromFile(self):
"""
Loads chached data from a local file
"""
f = open(self._filename, "r")
(tasks, categories) = pickle.load(f)
f.close()
return tasks, categories
def saveToFile(self, tasks, categories):
"""
Writes all cached data to a local file
"""
f = open(self._filename, "w")
pickle.dump((tasks, categories), f)
f.close()