On Tue, Jun 18, 2024 at 11:57:21AM +0200, Daniele Nicolodi wrote:
> The best documentation there is for beangulp is the example included in the
> repository https://github.com/beancount/beangulp/tree/master/examples and
> the docstrings in the code.
> 
> In a nutshell, to upgrade from beancount.ingest to beangulp, it shoul be
> sufficient to modify all Python imports from the beancount.ingest namespace
> to the beangulp namespace and to turn the configuration file that was used
> to be passed to bean-extract into a self-standing script as demonstrated
> here https://github.com/beancount/beangulp/blob/master/examples/import.py
> Then, calling such script with a '--help' argument should be enough to
> understand how to use it.

Thanks a lot for the above indications, which got me started.

I got stuck on a type error though, which I'm mentioning here in case it
helps other migrating and/or you want to change something about it:

  Traceback (most recent call last):
    File "/home/zack/dati/ledger/bin/bean-extract.py", line 86, in <module>
      ingest = beangulp.Ingest(importers, hooks)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File 
"/home/zack/.cache/virtualenvs/ledger3/lib/python3.11/site-packages/beangulp/__init__.py",
 line 258, in __init__
      self.importers = [_importer(i) for i in importers]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File 
"/home/zack/.cache/virtualenvs/ledger3/lib/python3.11/site-packages/beangulp/__init__.py",
 line 258, in <listcomp>
      self.importers = [_importer(i) for i in importers]
                        ^^^^^^^^^^^^
    File 
"/home/zack/.cache/virtualenvs/ledger3/lib/python3.11/site-packages/beangulp/__init__.py",
 line 253, in _importer
      raise TypeError(f'expected bengulp.Importer not {type(importer):}')
  TypeError: expected bengulp.Importer not <class 'type'>

My v2 type hierarchy looked (for a specific importer example) like this:

  AmexImporter -> CsvImporter -> importer.ImporterProtocol

Back then (v2) one should inherit from ImporterProtocol, whereas now
(v3) one should inherit from beangulp.Importer, like in the examples;
correct? But then, if I change my hierarchy to match, I get an even
nastier type error in the same place:

  TypeError: expected bengulp.Importer not <class 'abc.ABCMeta'>

I'm tempted at this point to nuke everything and restart from scratch
using the new csvbase.Importer. But maybe I'm missing something about
why the trivial migration that you were suggesting isn't working in my
case.

Thanks in advance!
Cheers
-- 
Stefano Zacchiroli . [email protected] . https://upsilon.cc/zack  _. ^ ._
Full professor of Computer Science              o     o   o     \/|V|\/
Télécom Paris, Polytechnic Institute of Paris     o     o o    </>   <\>
Co-founder & CTO Software Heritage            o o o     o       /\|^|/\
https://twitter.com/zacchiro . https://mastodon.xyz/@zacchiro   '" V "'

-- 
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/20240707120643.vbzpl3feurp2szpe%40upsilon.cc.

Reply via email to