Make language attributes abstract properties

This will make it impossible to create a new client without at least
having to define these properties. Which should get someone thinking
about language support…
This commit is contained in:
Chris Hill-Scott
2020-12-24 15:19:46 +00:00
parent c3a1d5c506
commit 9825469613

View File

@@ -1,4 +1,5 @@
import json import json
from abc import ABC, abstractmethod
import boto3 import boto3
from flask import current_app from flask import current_app
@@ -49,11 +50,18 @@ class CBCProxyClient:
return proxy_classes[provider](self._lambda_client) return proxy_classes[provider](self._lambda_client)
class CBCProxyClientBase: class CBCProxyClientBase(ABC):
lambda_name = None lambda_name = None
LANGUAGE_ENGLISH = 'en-GB' @property
LANGUAGE_WELSH = 'cy-GB' @abstractmethod
def LANGUAGE_ENGLISH(self):
pass
@property
@abstractmethod
def LANGUAGE_WELSH(self):
pass
def __init__(self, lambda_client): def __init__(self, lambda_client):
self._lambda_client = lambda_client self._lambda_client = lambda_client
@@ -128,6 +136,9 @@ class CBCProxyCanary(CBCProxyClientBase):
""" """
lambda_name = 'canary' lambda_name = 'canary'
LANGUAGE_ENGLISH = None
LANGUAGE_WELSH = None
def send_canary( def send_canary(
self, self,
identifier, identifier,
@@ -138,6 +149,9 @@ class CBCProxyCanary(CBCProxyClientBase):
class CBCProxyEE(CBCProxyClientBase): class CBCProxyEE(CBCProxyClientBase):
lambda_name = 'bt-ee-1-proxy' lambda_name = 'bt-ee-1-proxy'
LANGUAGE_ENGLISH = 'en-GB'
LANGUAGE_WELSH = 'cy-GB'
def send_link_test( def send_link_test(
self, self,
identifier, identifier,