base.py 921 B

12345678910111213141516171819202122232425262728293031323334
  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. RemoteStore abstract base class file
  6. """
  7. from abc import ABCMeta, abstractmethod
  8. import arrow
  9. import re
  10. class RemoteStore(metaclass=ABCMeta):
  11. """
  12. The RemoteStore abstract class
  13. """
  14. def __init__(self, name=None, backend='swift', date=None, store_options={}):
  15. """
  16. RemoteStore object is defined by a name and a backend
  17. """
  18. self.name = name
  19. self.date = date or arrow.now().strftime('%F_%T')
  20. self.backend = backend
  21. self.store_options = {
  22. re.sub('^opt_', '', k): v for k, v in store_options.items() if k.startswith('opt_')
  23. }
  24. @abstractmethod
  25. def send(self, files=[]):
  26. """
  27. Send method that should be implemented by the backend
  28. """