mirror of
https://github.com/subutux/rmapy.git
synced 2025-12-10 07:25:34 +00:00
Added documentation
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
from .document import Document
|
||||
from .folder import Folder
|
||||
from typing import NoReturn, TypeVar
|
||||
from typing import NoReturn, TypeVar, List
|
||||
from .exceptions import FolderNotFound
|
||||
|
||||
DocOrFolder = TypeVar('DocumentOrFolder', Document, Folder)
|
||||
|
||||
|
||||
class Collection(object):
|
||||
"""
|
||||
A collection of meta items
|
||||
"""A collection of meta items
|
||||
|
||||
This is basicly the content of the Remarkable Cloud.
|
||||
Attributes:
|
||||
items: A list containing the items.
|
||||
"""
|
||||
items = []
|
||||
|
||||
@@ -16,18 +20,36 @@ class Collection(object):
|
||||
self.items.append(i)
|
||||
|
||||
def add(self, docdict: dict) -> NoReturn:
|
||||
"""Add an item to the collection.
|
||||
It wraps it in the correct class based on the Type parameter of the
|
||||
dict.
|
||||
|
||||
Args:
|
||||
docdict: A dict representing a document or folder.
|
||||
"""
|
||||
|
||||
if docdict.get("Type", None) == "DocumentType":
|
||||
return self.addDocument(docdict)
|
||||
return self.add_document(docdict)
|
||||
elif docdict.get("Type", None) == "CollectionType":
|
||||
return self.addFolder(docdict)
|
||||
return self.add_folder(docdict)
|
||||
else:
|
||||
raise TypeError("Unsupported type: {_type}"
|
||||
.format(_type=docdict.get("Type", None)))
|
||||
|
||||
def addDocument(self, docdict: dict) -> NoReturn:
|
||||
def add_document(self, docdict: dict) -> NoReturn:
|
||||
"""Add a document to the collection
|
||||
|
||||
Args:
|
||||
docdict: A dict respresenting a document.
|
||||
"""
|
||||
self.items.append(Document(**docdict))
|
||||
|
||||
def addFolder(self, dirdict: dict) -> NoReturn:
|
||||
def add_folder(self, dirdict: dict) -> NoReturn:
|
||||
"""Add a document to the collection
|
||||
|
||||
Args:
|
||||
dirdict: A dict respresenting a folder.
|
||||
"""
|
||||
self.items.append(Folder(**dirdict))
|
||||
|
||||
def parent(self, docorfolder: DocOrFolder) -> Folder:
|
||||
|
||||
Reference in New Issue
Block a user