Skip to content

Commit

Permalink
Removed unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
RishiDiwanTT committed Oct 31, 2023
1 parent 7c4fb18 commit 064ff50
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
8 changes: 0 additions & 8 deletions api/s3_analytics_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import string
from typing import TYPE_CHECKING, Dict, Optional

from flask_babel import lazy_gettext as _

from core.config import CannotLoadConfiguration
from core.local_analytics_provider import LocalAnalyticsProvider
from core.model import Library, LicensePool, MediaTypes
Expand All @@ -19,9 +17,6 @@
class S3AnalyticsProvider(LocalAnalyticsProvider):
"""Analytics provider storing data in a S3 bucket."""

NAME = _("S3 Analytics")
DESCRIPTION = _("Store analytics events in a S3 bucket.")

def __init__(self, s3_service: Optional[S3Service]):
self.s3_service = s3_service

Expand Down Expand Up @@ -234,6 +229,3 @@ def _get_storage(self) -> S3Service:
)

return self.s3_service


Provider = S3AnalyticsProvider
9 changes: 0 additions & 9 deletions core/local_analytics_provider.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from flask_babel import lazy_gettext as _
from sqlalchemy.orm.session import Session

from core.model import CirculationEvent
from core.util.log import LoggerMixin


class LocalAnalyticsProvider(LoggerMixin):
NAME = _("Local Analytics")

DESCRIPTION = _("Store analytics events in the 'circulationevents' database table.")

# A given site can only have one analytics provider.
CARDINALITY = 1

Expand Down Expand Up @@ -39,7 +34,3 @@ def collect_event(
start=time,
library=library,
)


# The Analytics class looks for the name "Provider".
Provider = LocalAnalyticsProvider
17 changes: 1 addition & 16 deletions core/service/configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from pathlib import Path
from typing import Any, Type, TypeVar
from typing import Any, TypeVar

from pydantic import BaseSettings, ValidationError

Expand Down Expand Up @@ -54,18 +54,3 @@ def __init__(self, *args: Any, **kwargs: Any):
env_var_name = f"{self.__config__.env_prefix}{error_location}"
error_log_message += f"\n {env_var_name}: {error['msg']}"
raise CannotLoadConfiguration(error_log_message) from error_exception

@classmethod
def from_values(cls: Type[T], **values: Any) -> T:
"""
Construct a configuration using the `values` and defaults as priority,
other sources will be used as per their priority
"""
schema = cls.schema()
all_values = {}
for key, value_schema in schema["properties"].items():
if key in values:
all_values[key] = values[key]
elif "default" in value_schema:
all_values[key] = value_schema["default"]
return cls(**all_values)

0 comments on commit 064ff50

Please sign in to comment.