summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anderson <ejona86@gmail.com>2010-08-21 14:49:46 -0500
committerEric Anderson <ejona86@gmail.com>2010-08-21 14:49:46 -0500
commit75d8efcf9f4d908736e1dfb3e2ae9b09fa8b1336 (patch)
tree146070b9216b66302d9bdf8098002e81b8384742
parentda0ce517795493bd348e5b28dfbd764bc2d9f484 (diff)
downloadfeed-transmission-75d8efcf9f4d908736e1dfb3e2ae9b09fa8b1336.tar.gz
feed-transmission-75d8efcf9f4d908736e1dfb3e2ae9b09fa8b1336.zip
Save config on exit and fix config saving bugs
-rw-r--r--feed-transmission.example.json4
-rwxr-xr-xfeed-transmission.py13
2 files changed, 7 insertions, 10 deletions
diff --git a/feed-transmission.example.json b/feed-transmission.example.json
index 7252575..497ba3c 100644
--- a/feed-transmission.example.json
+++ b/feed-transmission.example.json
@@ -3,16 +3,12 @@
{
"matches": [
{
- "type": "re",
"value": ".*Thread: Some thread",
"white": true,
- "matched_count": 0
},
{
- "type": "re",
"value": ".*Thread: Some other thread",
"white": true,
- "matched_count": 0
],
"name": "example.com",
"poll_delay": 3600,
diff --git a/feed-transmission.py b/feed-transmission.py
index 167dd6b..deff6b8 100755
--- a/feed-transmission.py
+++ b/feed-transmission.py
@@ -63,8 +63,9 @@ class App(ConfigParticipant):
fd.close()
def save_config(self):
+ config = self.export_config()
fd = file(self.config_filename, "w")
- json.dump(self.export_data(), fd)
+ json.dump(config, fd, indent = 4)
fd.close()
def load_data(self, json_filename):
@@ -78,8 +79,9 @@ class App(ConfigParticipant):
fd.close()
def save_data(self):
+ data = self.export_data()
fd = file(self.data_filename, "w")
- json.dump(self.export_data(), fd)
+ json.dump(data, fd)
fd.close()
def import_config(self, config):
@@ -205,7 +207,7 @@ class Feed(ConfigParticipant):
"url": self.url,
"poll_delay": self.poll_delay,
"matches": [m.export_config() for m in self.matches],
- "default_white": self.white,
+ "default_white": self.default_white,
}
def import_data(self, data):
@@ -232,15 +234,13 @@ class Matcher(ConfigParticipant):
m = Matcher()
m.white = m._import_attribute(config, "white", bool, m.white)
m.str = m._import_attribute(config, "value", str, m.str)
- m.matched_count = m._import_attribute(config, "matched_count", int, m.matched_count)
m.re = re.compile(m.str)
return m
def export_config(self):
return {
"white": self.white,
- "str": self.str,
- "matched_count": self.matched_count,
+ "value": self.str,
}
def import_data(self, data):
@@ -260,4 +260,5 @@ if __name__ == "__main__":
app.load_data(".feed-transmission.data")
app.setup_env()
app.main()
+ app.save_config()