small fixes on --config and --unconfig
[ccoop.git] / ccoop-atomize.py
1 #!/usr/bin/env python
2
3 import sys, os
4
5 account=sys.argv[1]
6 name=sys.argv[2]
7 balance=sys.argv[3]
8
9 lines = file(os.path.join(os.getenv("CCPATH"), account+".csv")).readlines()
10 nlines = len(lines)
11
12 print '<?xml version="1.0" encoding="UTF-8"?>'
13 print '<feed xmlns="http://www.w3.org/2005/Atom">'
14 print "<title>"+name+" "+account+"</title>"
15 print '<subtitle type="text">Balance: '+balance+'</subtitle>'
16  
17 iline = 0
18 for line in lines:
19     line = line[:-1]
20     iline+=1
21     if not line:
22         continue
23     date,libel1,libel2,amount,sign,checkid = line.split(';')
24     date=date[6:]+"-"+date[3:5]+"-"+date[0:2]
25     libel1=libel1.strip()
26     libel2=libel2.strip()
27     amount=amount.strip()
28     sign=sign.strip()
29     print "<entry>"
30     print "   <id>"+str(nlines-iline)+"</id>"
31     print "   <updated>"+date+"</updated>"
32     print "   <title>"+libel1+"</title>"
33     print "   <content type='text'>"
34     print "      "+libel1
35     print "      "+libel2
36     print "      "+sign
37     print "      "+amount
38     print "      "+checkid
39     print "   </content>"
40     print "</entry>"
41
42 print "</feed>"