|
29 | 29 | from string import Template |
30 | 30 | from textwrap import dedent |
31 | 31 |
|
| 32 | +from hamster import client |
32 | 33 | from hamster.lib import datetime as dt |
33 | 34 | from hamster.lib.configuration import runtime |
34 | 35 | from hamster.lib import stuff |
@@ -57,6 +58,8 @@ def simple(facts, start_date, end_date, format, path = None): |
57 | 58 | writer = ICalWriter(report_path) |
58 | 59 | elif format == "hamster": |
59 | 60 | writer = HamsterWriter(report_path) |
| 61 | + elif format == "external": |
| 62 | + writer = ExternalWriter(report_path) |
60 | 63 | else: #default to HTML |
61 | 64 | writer = HTMLWriter(report_path, start_date, end_date) |
62 | 65 |
|
@@ -168,6 +171,24 @@ def _write_fact(self, fact): |
168 | 171 | def _finish(self, facts): |
169 | 172 | pass |
170 | 173 |
|
| 174 | +class ExternalWriter(ReportWriter): |
| 175 | + def __init__(self, path): |
| 176 | + ReportWriter.__init__(self, path) |
| 177 | + self.storage = client.Storage() |
| 178 | + |
| 179 | + def _write_fact(self, fact): |
| 180 | + exported = self.storage.export_fact(fact.id) |
| 181 | + if exported: |
| 182 | + self.file.write(_("Exported: %s - %s") % (fact.activity, fact.delta) + "\n") |
| 183 | + fact.exported = True |
| 184 | + self.storage.update_fact(fact.id, fact, False) |
| 185 | + pass |
| 186 | + else: |
| 187 | + self.file.write(_("Fact not exported: %s" % fact.activity) + "\n") |
| 188 | + |
| 189 | + def _finish(self, facts): |
| 190 | + pass |
| 191 | + |
171 | 192 | class XMLWriter(ReportWriter): |
172 | 193 | def __init__(self, path): |
173 | 194 | ReportWriter.__init__(self, path) |
|
0 commit comments