diff --git a/.gitignore b/.gitignore index a02eb483..1aaf0db6 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,9 @@ htmlcov/ .cover .pybuilder/ +# Astro +.astro/ + # Celery celerybeat-schedule celerybeat.pid diff --git a/core/vendors/__init__.py b/core/vendors/__init__.py index e5a8f0c8..e66d8e99 100644 --- a/core/vendors/__init__.py +++ b/core/vendors/__init__.py @@ -37,7 +37,7 @@ class AbstractVendor: if total == 0: return [] chunk_size = max(1, (total + num_chunks - 1) // num_chunks) - return [data[i : i + chunk_size] for i in range(0, total, chunk_size)] + return [data[i: i + chunk_size] for i in range(0, total, chunk_size)] @staticmethod def auto_convert_value(value): @@ -85,7 +85,7 @@ class AbstractVendor: # Try to detect a JSON object or array. stripped_value = value.strip() if (stripped_value.startswith("{") and stripped_value.endswith("}")) or ( - stripped_value.startswith("[") and stripped_value.endswith("]") + stripped_value.startswith("[") and stripped_value.endswith("]") ): with suppress(Exception): parsed = json.loads(value) @@ -162,13 +162,13 @@ class AbstractVendor: return round(price, 2) - def resolve_price_with_currency(self, price, provider): + def resolve_price_with_currency(self, price, provider, currency=None): rates = get_rates(provider) - rate = rates.get(self.currency) + rate = rates.get(currency or self.currency) if not rate: - raise RatesError(f"No rate found for {self.currency} in {rates} with probider {provider}...") + raise RatesError(f"No rate found for {currency or self.currency} in {rates} with probider {provider}...") return round(price / rate, 2) if rate else round(price, 2)