-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.py
143 lines (113 loc) · 4.45 KB
/
entry.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python
# Copyright 2011 by Andreas Pakulat <[email protected]>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
from qsettingsutils import _readQSettingsBoolEntry
class Entry(object):
def __init__(self):
self._url = None
self._updated = None
self._title = None
self._id = None
self._content = None
self._author = None
self._read = False
self._important = False
def __hash__(self):
if not self._id is None and len(self._id) > 0:
return hash(self._id)
return 3 * hash(self._title) \
+ 5 * hash(self._author) \
+ 7 * hash(self._url) \
+ 13 * hash(self._important) \
+ 17 * hash(self._read)
def _getread(self):
return self._read
def _setread(self, read):
self._read = read
read = property(_getread, _setread, None, \
"Wether this entry was read already")
def _geturl(self):
return self._url
def _seturl(self, url):
self._url = url
url = property(_geturl, _seturl, None, "Url of this entry")
def _getimportant(self):
return self._important
def _setimportant(self, important):
self._important = important
important = property(_getimportant, _setimportant, None, "Important Mark")
def _getupdated(self):
return self._updated
def _setupdated(self, updated):
self._updated = updated
updated = property(_getupdated, _setupdated, None, \
"Date of last update of this entry")
def _gettitle(self):
return self._title
def _settitle(self, title):
self._title = title
title = property(_gettitle, _settitle, None, "Title of this entry")
def _getid(self):
return self._id
def _setid(self, identity):
self._id = identity
identity = property(_getid, _setid, None, "Id of this entry")
def _getauthor(self):
return self._author
def _setauthor(self, author):
self._author = author
author = property(_getauthor, _setauthor, None, "Author of this entry")
def _getcontent(self):
return self._content
def _setcontent(self, content):
self._content = content
content = property(_getcontent, _setcontent, None, "Content of this entry")
def load(self, store):
self.title = store.value("Title", None)
self.author = store.value("Author", None)
self.content = store.value("Content", None)
self.updated = store.value("Updated", None)
self.url = store.value("Url", None)
self.identity = store.value("Id", None)
self.read = _readQSettingsBoolEntry(store, "Read", False)
self.important = _readQSettingsBoolEntry(store, "Important", False)
def save(self, store):
store.setValue("Title", self.title)
store.setValue("Author", self.author)
store.setValue("Content", self.content)
store.setValue("Updated", self.updated)
store.setValue("Url", self.url)
store.setValue("Id", self.identity)
store.setValue("Read", self.read)
store.setValue("Important", self.important)
def __lt__(self, other):
return self.updated < other.updated
def __eq__(self, other):
if other is None:
return False
return (self.title == other.title \
and self.author == other.author \
and self.identity == other.identity \
and self.url == other.url \
and self.read == other.read \
and self.important == other.important \
and self.updated == other.updated \
and self.content == other.content)
if __name__ == "__main__":
import sys
print "Cannot run this module"
sys.exit(1)