Commit 6ababdc4 authored by Florian Fuchs's avatar Florian Fuchs

Added ``_ListArchivers`` docstrings and a couple of comments.

parent c7998081
......@@ -449,8 +449,7 @@ class _List:
@property
def archivers(self):
"""
Returns a dict of all available archivers, along with their
activation status.
Returns a _ListArchivers instance.
"""
url = 'lists/{0}/archivers'.format(self.list_id)
return _ListArchivers(self._connection, url, self)
......@@ -561,8 +560,20 @@ class _List:
class _ListArchivers:
"""
Represents the activation status for each site-wide available archiver
for a given list.
"""
def __init__(self, connection, url, list_obj):
"""
:param connection: An API connection object.
:type connection: _Connection.
:param url: The API url of the list's archiver endpoint.
:param url: str.
:param list_obj: The corresponding list object.
:type list_obj: _List.
"""
self._connection = connection
self._url = url
self._list_obj = list_obj
......@@ -573,9 +584,11 @@ class _ListArchivers:
return '<Archivers on "{0}">'.format(self._list_obj.list_id)
def _get_info(self):
# Get data from API; only once per instance.
if self._info is None:
response, content = self._connection.call(self._url)
# Remove `http_etag` from dictionary.
# Remove `http_etag` from dictionary, we only want
# the archiver info.
content.pop('http_etag')
self._info = content
......@@ -586,11 +599,14 @@ class _ListArchivers:
def __getitem__(self, key):
self._get_info()
# No precautions against KeyError, should behave like a dict.
return self._info[key]
def __setitem__(self, key, value):
self._get_info()
# No precautions against KeyError, should behave like a dict.
self._info[key] = value
# Update archiver status via the API.
self._connection.call(self._url, self._info, method='PUT')
def keys(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment