I would create an importer module for your institution, in say 
importers/institution/csv.py. Make sure you indicate these directories as 
Python packages with appropriate __init__ files.

In that module import the built-in csv import module: 
from beancount.ingest.importers import csv

Subclass the Importer defined in that module:
class Importer(csv.Importer):
Define your column mapping config, decorators and other jazz. Monkey patch 
functions in the csv module. In my case I chain a couple of decorators: 
csv.get_amounts = normalise(ignore_pending(csv.get_amounts))
Import and set config for your new importer class in your importer config 
module.

This won't trample the get_amounts function "seen" by other importers.

On Wednesday, May 20, 2020 at 3:19:17 AM UTC+10, [email protected] wrote:
>
>
>
> Thanks for the code. I was doing essentially the same thing as yours. But 
> as you mentioned, I did get tripped by the patching.
>
> I have two different bank statements needing two different patches. And 
> one importer indeed changes the behavior of the other. Any suggestion how 
> to do it properly? Thanks!
>
> W.E.
>
> On Saturday, May 16, 2020 at 10:00:44 PM UTC-4, [email protected] wrote
>
> If you haven't got a good handle on how Python namespaces work, you may 
>> get tripped up by monkey patching. Spend a bit of time getting familiar 
>> with it. You'll change the behaviour of your other importers depending on 
>> the CSV module if you're not careful.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/cc37d0db-19bb-43c1-bde5-0ebd6169776a%40googlegroups.com.

Reply via email to