Added support for downloading binary

This commit is contained in:
Rick Rongen
2019-02-14 16:27:58 +01:00
parent 96659dd9cb
commit e3319908a1
2 changed files with 24 additions and 0 deletions

View File

@@ -1,13 +1,25 @@
from logging import Logger
if False:
from .connection import Connection
LOGGER = Logger(__name__)
class SimpleNode:
def __init__(self, path: str, data: dict, connection: 'Connection'):
self.path = path
self._data = data
self._connection = connection
def download(self, key: str = 'jcr:data') -> bytes:
if ':' + key not in self._data:
LOGGER.warning(f"Key :{key} is not present, binary probably not available")
# TODO value of the :{key} must be an int
# TODO value denotes file size, warn/deny large files?
return self._connection.download_binary(self.path + '/' + key)
def __getitem__(self, item):
return getattr(self, item)