use abstract base class
parent
310d236390
commit
4484e4b95c
|
|
@ -1,13 +1,16 @@
|
|||
import datetime
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections import namedtuple
|
||||
|
||||
import requests
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
Status = namedtuple("Status", ['doorstate', 'timestamp', 'text'])
|
||||
|
||||
class Source:
|
||||
class Source(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def get_status(self):
|
||||
raise NotImplementedError()
|
||||
pass
|
||||
|
||||
def is_recent(self, status, **kwargs):
|
||||
return status.timestamp + datetime.timedelta(days=1) < datetime.datetime.today()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import requests
|
||||
|
||||
|
|
@ -6,9 +7,10 @@ from matrix_client.client import MatrixClient as MatrixApiClient
|
|||
from matrix_client.errors import MatrixError
|
||||
|
||||
|
||||
class Client:
|
||||
class Client(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
raise NotImplementedError()
|
||||
pass
|
||||
|
||||
def post_image(self, file, name, content_type="image/png", targets=None):
|
||||
"""Push to all targets"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue