mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Some internal documentation improvements.
This commit is contained in:
parent
7eedb170a2
commit
5f27d25b3c
2 changed files with 36 additions and 24 deletions
|
|
@ -108,6 +108,6 @@ Read-only storages
|
||||||
|
|
||||||
These storages don't support writing of their items, consequently ``read_only``
|
These storages don't support writing of their items, consequently ``read_only``
|
||||||
is set to ``True`` by default. Changing ``read_only`` to ``False`` on them
|
is set to ``True`` by default. Changing ``read_only`` to ``False`` on them
|
||||||
might eventually lead to a crash of vdirsyncer when trying to write to them.
|
leads to an error.
|
||||||
|
|
||||||
.. autoclass:: HttpStorage
|
.. autoclass:: HttpStorage
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,27 @@ class Storage(object):
|
||||||
to many collections (e.g. a vdir) and the given collection name will be
|
to many collections (e.g. a vdir) and the given collection name will be
|
||||||
looked for.
|
looked for.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
fileext = '.txt'
|
fileext = '.txt'
|
||||||
storage_name = None # the name used in the config file
|
storage_name = None # The name used in the config file.
|
||||||
|
|
||||||
|
# A value of True means the storage does not support write-methods such as
|
||||||
|
# upload, update and delete. A value of False means the storage does
|
||||||
|
# support those methods, but it may also be used in read-only mode.
|
||||||
read_only = None
|
read_only = None
|
||||||
|
|
||||||
|
# The attribute values to show in the representation of the storage.
|
||||||
_repr_attributes = ()
|
_repr_attributes = ()
|
||||||
|
|
||||||
def __init__(self, read_only=None):
|
def __init__(self, read_only=None):
|
||||||
if read_only is None:
|
if self.read_only and not read_only:
|
||||||
read_only = self.read_only
|
raise ValueError('This storage is read-only.')
|
||||||
if self.read_only is not None and read_only != self.read_only:
|
|
||||||
raise ValueError('read_only must be {}'
|
|
||||||
.format(repr(self.read_only)))
|
|
||||||
self.read_only = bool(read_only)
|
self.read_only = bool(read_only)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def discover(cls, **kwargs):
|
def discover(cls, **kwargs):
|
||||||
'''
|
'''Discover collections given a basepath or -URL to many collections.
|
||||||
Discover collections given a basepath or -URL to many collections.
|
|
||||||
:param **kwargs: Keyword arguments to additionally pass to the storage
|
:param **kwargs: Keyword arguments to additionally pass to the storage
|
||||||
instances returned. You shouldn't pass `collection` here, otherwise
|
instances returned. You shouldn't pass `collection` here, otherwise
|
||||||
TypeError will be raised.
|
TypeError will be raised.
|
||||||
|
|
@ -75,7 +79,8 @@ class Storage(object):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def get(self, href):
|
def get(self, href):
|
||||||
'''
|
'''Fetch a single item.
|
||||||
|
|
||||||
:param href: href to fetch
|
:param href: href to fetch
|
||||||
:returns: (item, etag)
|
:returns: (item, etag)
|
||||||
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if item can't
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if item can't
|
||||||
|
|
@ -84,7 +89,11 @@ class Storage(object):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def get_multi(self, hrefs):
|
def get_multi(self, hrefs):
|
||||||
'''
|
'''Fetch multiple items.
|
||||||
|
|
||||||
|
Functionally similar to :py:meth:`get`, but might bring performance
|
||||||
|
benefits on some storages when used cleverly.
|
||||||
|
|
||||||
:param hrefs: list of hrefs to fetch
|
:param hrefs: list of hrefs to fetch
|
||||||
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if one of the
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if one of the
|
||||||
items couldn't be found.
|
items couldn't be found.
|
||||||
|
|
@ -95,8 +104,8 @@ class Storage(object):
|
||||||
yield href, item, etag
|
yield href, item, etag
|
||||||
|
|
||||||
def has(self, href):
|
def has(self, href):
|
||||||
'''
|
'''Check if an item exists by its href.
|
||||||
check if item exists by href
|
|
||||||
:returns: True or False
|
:returns: True or False
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
|
|
@ -107,27 +116,30 @@ class Storage(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def upload(self, item):
|
def upload(self, item):
|
||||||
'''
|
'''Upload a new item.
|
||||||
Upload a new item, raise
|
|
||||||
:exc:`vdirsyncer.exceptions.PreconditionFailed` if it already exists.
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if there is
|
||||||
|
already an item with that href.
|
||||||
|
|
||||||
:returns: (href, etag)
|
:returns: (href, etag)
|
||||||
'''
|
'''
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def update(self, href, item, etag):
|
def update(self, href, item, etag):
|
||||||
'''
|
'''Update an item.
|
||||||
Update the item, raise
|
|
||||||
:exc:`vdirsyncer.exceptions.PreconditionFailed` if the etag on the
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` if the etag on
|
||||||
server doesn't match the given etag or if the item doesn't exist.
|
the server doesn't match the given etag or if the item doesn't
|
||||||
|
exist.
|
||||||
|
|
||||||
:returns: etag
|
:returns: etag
|
||||||
'''
|
'''
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def delete(self, href, etag):
|
def delete(self, href, etag):
|
||||||
'''
|
'''Delete an item by href.
|
||||||
Delete the item by href, raise
|
|
||||||
:exc:`vdirsyncer.exceptions.PreconditionFailed` when item has a
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` when item has
|
||||||
different etag or doesn't exist.
|
a different etag or doesn't exist.
|
||||||
'''
|
'''
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue