base_non_rdf_layout.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import logging
  2. from abc import ABCMeta, abstractmethod
  3. from lakesuperior.config_parser import config
  4. class BaseNonRdfLayout(metaclass=ABCMeta):
  5. '''
  6. Abstract class for setting the non-RDF (bitstream) store layout.
  7. Differerent layouts can be created by implementing all the abstract methods
  8. of this class. A non-RDF layout is not necessarily restricted to a
  9. traditional filesystem—e.g. a layout persisting to HDFS can be written too.
  10. '''
  11. _conf = config['application']['store']['ldp_nr']
  12. _logger = logging.getLogger(__name__)
  13. def __init__(self):
  14. '''
  15. Initialize the base non-RDF store layout.
  16. '''
  17. self.root = self._conf['path']
  18. ## INTERFACE METHODS ##
  19. @abstractmethod
  20. def persist(self, stream):
  21. '''
  22. Store the stream in the designated persistence layer for this layout.
  23. '''
  24. pass
  25. @abstractmethod
  26. def delete(self, id):
  27. '''
  28. Delete a stream by its identifier (i.e. checksum).
  29. '''
  30. pass
  31. @abstractmethod
  32. def local_path(self, uuid):
  33. '''
  34. Return the local path of a file.
  35. '''
  36. pass