Wednesday, September 9, 2015

A scrambled SEPA file

Working on #505.

I wrote a new demo fixture lino_xl.lib.sepa.fixtures.sample_ibans.

Here is a script to be executed with run which scrambles a SEPA file of bank statements:

# usage 
import sys
from lino.api.shell import contacts
from lxml import etree
from lino.utils import Cycler

from lino_xl.lib.sepa.fixtures.sample_ibans import IBANS

IBANS = Cycler(IBANS)
PARTNERS = Cycler(contacts.Partner.objects.all())

tree = etree.parse(sys.argv[1])

for e in tree.getroot().getiterator():
    if e.tag.endswith("}IBAN"):
        e.text = IBANS.pop()
    if e.tag.endswith("}Nm"):
        e.text = PARTNERS.pop().name

print etree.tostring(tree)

What it does:

AttributeError: type object ‘Model’ has no attribute ‘_meta’

Discovered bug #516, wrote a test case (in a new document Generic Foreign Keys), fixed the bug.