hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
496 stars 97 forks source link

Replaced CurrencyConverter #441

Closed set-soft closed 3 years ago

set-soft commented 3 years ago

This patch adds a small internal module to remove the CurrencyConverter dependency. The replacement always does a request for the exchange rates. It doesn't rely on a hardcoded database that gets outdated as soon as we do a release. It has a fallback in case the request fail. The patch also adds a tool to update the fallback before a release.

set-soft commented 3 years ago

Note that I put this submodule under the Apache 2.0 license because it is "inspired" on the original CurrencyConverter, released using Apache 2.0. The implementation is quite different, but I think this is fair. Also note that this module introduces one extra HTTP request, but KiCost needs HTTP requests to find the components. This request is done only when we need a currency conversion. I'm using bs4 to parse the XML to avoid any extra dependency. I'm not printing any warning if we fail to get the current exchange rates. This is because I don't know what's the best way to do it from KiCost point. I'm silently using the included exchange rates. BTW, I can't beleive the original package is pushing a 500 kB .zip for every update, defeating the GIT idea and generating a 128 MB repo.

hildogjr commented 3 years ago

I am also have some question about how exactly it will work. I have to do some tests.

To final spreadsheet, the current rate is saved into a cell bellow the global part and the user can change it any time. This is a workaround to fill with the exactly credit-card currency rate used.