use abstract base class

master
Clemens Klug 2018-05-28 14:47:56 +02:00
parent 310d236390
commit 4484e4b95c
2 changed files with 10 additions and 5 deletions

View File

@ -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()

View File

@ -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"""