GTG

Merge lp:~bryce/gtg/anon-noargs into lp:~gtg/gtg/old-trunk

Proposed by Bryce Harrington
Status: Merged
Merged at revision: 857
Proposed branch: lp:~bryce/gtg/anon-noargs
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 70 lines (+38/-8)
1 file modified
scripts/anonymize_task_file.py (+38/-8)
To merge this branch: bzr merge lp:~bryce/gtg/anon-noargs
Reviewer Review Type Date Requested Status
Marko Kevac Pending
Gtg developers Pending
Review via email: mp+29696@code.launchpad.net

Description of the change

This makes the anon tasks script use reasonable defaults when run with no args.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'scripts/anonymize_task_file.py'
--- scripts/anonymize_task_file.py 2010-06-11 14:50:21 +0000
+++ scripts/anonymize_task_file.py 2010-07-12 13:12:39 +0000
@@ -1,5 +1,5 @@
1#!/usr/bin/env python1#!/usr/bin/env python
2# -*- coding: UTF-8 -*-2### -*- coding: utf-8 -*-
3# Copyright © 2010 Marko Kevac <marko@kevac.org>3# Copyright © 2010 Marko Kevac <marko@kevac.org>
4#4#
5# This program is free software: you can redistribute it and/or modify5# This program is free software: you can redistribute it and/or modify
@@ -15,8 +15,10 @@
15# You should have received a copy of the GNU General Public License15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18import os
18import sys19import sys
19from xml.dom.minidom import parse20from xml.dom.minidom import parse
21from xdg.BaseDirectory import xdg_data_home
2022
21def anonymize(filename, outputfile):23def anonymize(filename, outputfile):
2224
@@ -64,14 +66,42 @@
64 except Exception, err:66 except Exception, err:
65 print "error while saving output file: %s" % err67 print "error while saving output file: %s" % err
6668
69def usage():
70 print "Usage: %s [taskfile] [outputfile]" % sys.argv[0]
71 print
72 print "Removes private data from specified taskfile, or your"
73 print "default gtg tasks file if unspecified. Writes output"
74 print "to /tmp/gtg-tasks.xml by default, or to specified"
75 print "outputfile if provided."
76 sys.exit(1)
77
67def main():78def main():
68 if len(sys.argv) != 3:79 #if len(sys.argv) != 3:
69 print "Remove private data from your tasks file."80 # usage()
70 print "Usage: %s <taskfile> <outputfile>" % sys.argv[0]81
71 sys.exit(1)82 if len(sys.argv) > 1:
7283 xmlfile = sys.argv[1]
73 xmlfile = sys.argv[1]84 else:
74 outputfile = sys.argv[2]85 try:
86 # Or use CoreConfig().get_data_dir() . CoreConfig.???
87 # which needs 'from GTG.core import import CoreConfig'
88 data_dir = os.path.join(xdg_data_home, "gtg")
89 project_filepath = os.path.join(data_dir, "projects.xml")
90 dom = parse(project_filepath)
91 xmlproject = dom.getElementsByTagName("backend")[0]
92 xmlfile = str(xmlproject.getAttribute("path"))
93
94 print "Reading tasks from %s" %(xmlfile)
95 except:
96 print
97 usage()
98
99 if len(sys.argv) > 2:
100 outputfile = sys.argv[2]
101 else:
102 # Use a reasonable default, and write out where it's sent
103 outputfile = "/tmp/gtg-tasks.xml"
104 print "Saving anonymized tasks to %s" %(outputfile)
75105
76 anonymize(xmlfile, outputfile)106 anonymize(xmlfile, outputfile)
77107

Subscribers

People subscribed via source and target branches

to status/vote changes: