/usr/share/pyshared/wxbanker/csvexporter.py is in wxbanker 0.9.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv, cStringIO
class CsvExporter:
"""Iterate through the list of transactions for an account and
exort to a CSV file."""
@staticmethod
def Generate(model, delimiter=",", quotechar="'"):
"""Generate the CSV string."""
result = cStringIO.StringIO()
writer = csv.writer(result, delimiter=delimiter, quotechar=quotechar)
writer.writerow(['Account', 'Description', 'Amount', 'Date'])
# Iterate through transaction list, write rows.
for account in model.Accounts:
for transaction in account.Transactions:
row = [account.Name.encode("utf8"), transaction.GetDescription().encode("utf8"), transaction.GetAmount(), transaction.GetDate()]
writer.writerow(row)
return result.getvalue().decode("utf8")
@staticmethod
def Export(model, exportPath):
# Generate the contents.
result = CsvExporter.Generate(model)
# Write it.
exportFile = open(exportPath, 'w')
exportFile.write(result.encode("utf8"))
|