base.py 945 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Use of this source code is governed by a BSD-style
  2. # license that can be found in the LICENSE file.
  3. # Copyright 2019 The OSArchiver Authors. All rights reserved.
  4. """
  5. Destination abstract base class file
  6. """
  7. from abc import ABCMeta, abstractmethod
  8. class Destination(metaclass=ABCMeta):
  9. """
  10. The Destination absrtact base class
  11. """
  12. def __init__(self, name=None, backend='db', conf=None):
  13. """
  14. Destination object is defined by a name and a backend
  15. """
  16. self.name = name
  17. self.backend = backend
  18. self.conf = conf
  19. @abstractmethod
  20. def write(self, database=None, table=None, data=None):
  21. """
  22. Write method that should be implemented by the backend
  23. """
  24. @abstractmethod
  25. def clean_exit(self):
  26. """
  27. clean_exit method that should be implemented by the backend
  28. provide a way to close and clean properly backend stuff
  29. """