redstreet / beancount_reds_plugins

Miscellaneous plugins for Beancount double entry accounting
GNU General Public License v3.0
95 stars 18 forks source link

Plain 'print' breaks CSV output #28

Closed mmoya closed 5 months ago

mmoya commented 5 months ago

This print breaks CSV output when using default config.

$ bean-query -f csv <(echo 'plugin "beancount_reds_plugins.effective_date.effective_date" ""') "SELECT *"
Using default config
date,flag,payee,narration,position
redstreet commented 5 months ago

Cool, thank you for filing. Any issues you see with printing to stderr instead?

mmoya commented 5 months ago

FTR, my workflow is:

import subprocess
import petl as etl

stdout = subprocess.check_output(["bean-query", "-f", "csv", ...], stderr=subprocess.DEVNULL)
table = etl.fromcsv(etl.MemorySource(stdout))

So printing to stderr is fine but I don't know if it's better to use logging to allow controlling output from higher level or even not printing at all because default config is fine and well documented.

It took me a lot to find the cause of an Using default config in the middle of several ledger errors. Adding some context like effective_date: Using default config would help with troubleshooting.

Thanks.

redstreet commented 5 months ago

Thanks for the feedback: given the default config feels fine and documented, I'll remove it, and put it inside a DEBUG block, which is the stand in for logging I currently have. Prepended effective_date as well. Done.