Rename rmapi rmapy

This commit is contained in:
Stijn Van Campenhout
2019-12-19 13:42:26 +01:00
parent 41ed56ace7
commit 00dc50550f
17 changed files with 90 additions and 91 deletions

View File

@@ -18,7 +18,7 @@ sys.path.insert(0, os.path.abspath('../..'))
# -- Project information -----------------------------------------------------
project = 'rmapi'
project = 'rmapy'
copyright = '2019, Stijn Van Campenhout'
author = 'Stijn Van Campenhout'

View File

@@ -1,9 +1,9 @@
.. rmapi documentation master file, created by
.. rmapy documentation master file, created by
sphinx-quickstart on Tue Sep 17 19:24:29 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to rmapi's documentation!
Welcome to rmapy's documentation!
=================================
This is an (unofficial) Remarkable Cloud API Client written in Python.
@@ -50,9 +50,9 @@ API Documentation
.. toctree::
:maxdepth: 2
rmapi
rmapy
.. automodule:: rmapi
.. automodule:: rmapy
Indices and tables

View File

@@ -1,11 +1,11 @@
Pip
===
Like any other package, you can install rmapi using pip:
Like any other package, you can install rmapy using pip:
.. code-block:: bash
pip install rmapi
pip install rmapy

View File

@@ -1,7 +1,7 @@
rmapi
rmapy
=====
.. toctree::
:maxdepth: 4
rmapi
rmapy

View File

@@ -22,20 +22,20 @@ and use the code you see on the webpage
:linenos:
from rmapi.api import Client
from rmapy.api import Client
rmapi = Client()
rmapy = Client()
# Shoud return False
rmapi.is_authenticated()
rmapy.is_authenticated()
# This registers the client as a new device. The received device token is
# stored in the users directory in the file ~/.rmapi, the same as with the
# go rmapi client.
rmapi.register_device("fkgzzklrs")
rmapy.register_device("fkgzzklrs")
# It's always a good idea to refresh the user token everytime you start
# a new session.
rmapi.refresh_token()
rmapy.refresh_token()
# Shoud return True
rmapi.is_authenticated()
rmapy.is_authenticated()
Working with items
~~~~~~~~~~~~~~~~~~
@@ -50,21 +50,21 @@ We can list the items in the Cloud
.. code-block:: python
:linenos:
>>> from rmapi.api import Client
>>> rmapi = Client()
>>> rmapi.renew_token()
>>> from rmapy.api import Client
>>> rmapy = Client()
>>> rmapy.renew_token()
True
>>> collection = rmapi.get_meta_items()
>>> collection = rmapy.get_meta_items()
>>> collection
<rmapi.collections.Collection object at 0x7fa1982d7e90>
<rmapy.collections.Collection object at 0x7fa1982d7e90>
>>> len(collection)
181
>>> # Count the amount of documents
... from rmapi.document import Document
... from rmapy.document import Document
>>> len([f for f in collection if isinstance(f, Document)])
139
>>> # Count the amount of folders
... from rmapi.folder import Folder
... from rmapy.folder import Folder
>>> len([f for f in collection if isinstance(f, Folder)])
42
@@ -74,7 +74,7 @@ DocumentType
````````````
A DocumentType is a document. This can be a pdf, epub or notebook.
These types are represented by the object :class:`rmapi.document.Document`
These types are represented by the object :class:`rmapy.document.Document`
Changing the metadata is easy
@@ -83,28 +83,28 @@ Changing the metadata is easy
:linenos:
>>> from rmapi.api import Client
>>> rmapi = Client()
>>> rmapi.renew_token()
>>> from rmapy.api import Client
>>> rmapy = Client()
>>> rmapy.renew_token()
True
>>> collection = rmapi.get_meta_items()
>>> collection = rmapy.get_meta_items()
>>> doc = [ d for d in collection if d.VissibleName == 'ModernC'][0]
>>> doc
<rmapi.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
<rmapy.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
>>> doc.to_dict()
{'ID': 'a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3', 'Version': 1, 'Message': '', 'Succes': True, 'BlobURLGet': '', 'BlobURLGetExpires': '0001-01-01T00:00:00Z', 'BlobURLPut': '', 'BlobURLPutExpires': '', 'ModifiedClient': '2019-09-18T20:12:07.206206Z', 'Type': 'DocumentType', 'VissibleName': 'ModernC', 'CurrentPage': 0, 'Bookmarked': False, 'Parent': ''}
>>> doc.VissibleName = "Modern C: The book of wisdom"
>>> # push the changes back to the Remarkable Cloud
... rmapi.update_metadata(doc)
... rmapy.update_metadata(doc)
True
>>> collection = rmapi.get_meta_items()
>>> collection = rmapy.get_meta_items()
>>> doc = [ d for d in docs if d.VissibleName == 'ModernC'][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> doc = [ d for d in docs if d.VissibleName == 'Modern C: The book of wisdom'][0]
>>> doc
<rmapi.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
<rmapy.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
>>> doc.to_dict()
{'ID': 'a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3', 'Version': 1, 'Message': '', 'Succes': True, 'BlobURLGet': '', 'BlobURLGetExpires': '0001-01-01T00:00:00Z', 'BlobURLPut': '', 'BlobURLPutExpires': '', 'ModifiedClient': '2019-09-18T20:12:07.206206Z', 'Type': 'DocumentType', 'VissibleName': 'Modern C: The book of wisdom', 'CurrentPage': 0, 'Bookmarked': False, 'Parent': ''}
@@ -114,7 +114,7 @@ CollectionType
A CollectionType is a Folder.
These types are represented by the object :class:`rmapi.folder.Folder`
These types are represented by the object :class:`rmapy.folder.Folder`
Working with folders is easy!
@@ -122,42 +122,42 @@ Working with folders is easy!
:linenos:
>>> from rmapi.api import Client
>>> rmapi = Client()
>>> rmapi.renew_token()
>>> from rmapy.api import Client
>>> rmapy = Client()
>>> rmapy.renew_token()
True
>>> collection = rmapi.get_meta_items()
>>> collection = rmapy.get_meta_items()
>>> collection
<rmapi.collections.Collection object at 0x7fc4718e1ed0>
>>> from rmapi.folder import Folder
<rmapy.collections.Collection object at 0x7fc4718e1ed0>
>>> from rmapy.folder import Folder
>>> # Get all the folders. Note that the fs of Remarkable is flat in the cloud
... folders = [ f for f in collection if isinstance(f, Folder) ]
>>> folders
[<rmapi.folder.Folder 028400f5-b258-4563-bf5d-9a47c314668c>, <rmapi.folder.Folder 06a36729-f91e-47da-b334-dc088c1e73d2>, ...]
[<rmapy.folder.Folder 028400f5-b258-4563-bf5d-9a47c314668c>, <rmapy.folder.Folder 06a36729-f91e-47da-b334-dc088c1e73d2>, ...]
>>> # Get the root folders
... root = [ f for f in folders if f.Parent == "" ]
>>> root
[<rmapi.folder.Folder 028400f5-b258-4563-bf5d-9a47c314668c>, <rmapi.folder.Folder 5005a085-d7ee-4867-8859-4cd90dee0d62>, ...]
[<rmapy.folder.Folder 028400f5-b258-4563-bf5d-9a47c314668c>, <rmapy.folder.Folder 5005a085-d7ee-4867-8859-4cd90dee0d62>, ...]
>>> # Create a new folder
... new_folder = Folder("New Folder")
>>> new_folder
<rmapi.folder.Folder 579df08d-7ee4-4f30-9994-887e6341cae3>
>>> rmapi.create_folder(new_folder)
<rmapy.folder.Folder 579df08d-7ee4-4f30-9994-887e6341cae3>
>>> rmapy.create_folder(new_folder)
True
>>> # verify
... [ f for f in rmapi.get_meta_items() if f.VissibleName == "New Folder" ]
[<rmapi.folder.Folder 579df08d-7ee4-4f30-9994-887e6341cae3>]
>>> [ f for f in rmapi.get_meta_items() if f.VissibleName == "New Folder" ][0].ID == new_folder.ID
... [ f for f in rmapy.get_meta_items() if f.VissibleName == "New Folder" ]
[<rmapy.folder.Folder 579df08d-7ee4-4f30-9994-887e6341cae3>]
>>> [ f for f in rmapy.get_meta_items() if f.VissibleName == "New Folder" ][0].ID == new_folder.ID
True
>>> # Move a document in a folder
... doc = rmapi.get_doc("a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3")
... doc = rmapy.get_doc("a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3")
>>> doc
<rmapi.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
<rmapy.document.Document a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3>
>>> doc.Parent = new_folder.ID
>>> # Submit the changes
... rmapi.update_metadata(doc)
... rmapy.update_metadata(doc)
True
>>> doc = rmapi.get_doc("a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3")
>>> doc = rmapy.get_doc("a969fcd6-64b0-4f71-b1ce-d9533ec4a2a3")
>>> doc.Parent == new_folder.ID
True
@@ -193,14 +193,14 @@ the remarkable file format:
:linenos:
>>> from rmapi.document import ZipDocument
>>> from rmapi.api import Client
>>> from rmapy.document import ZipDocument
>>> from rmapy.api import Client
>>> rm = Client()
>>> rm.renew_token()
True
>>> rawDocument = ZipDocument(doc="/home/svancampenhout/27-11-2019.pdf")
>>> rawDocument
<rmapi.document.ZipDocument b926ffc2-3600-460e-abfa-0fcf20b0bf99>
<rmapy.document.ZipDocument b926ffc2-3600-460e-abfa-0fcf20b0bf99>
>>> rawDocument.metadata["VissibleName"]
'27-11-2019'

View File

@@ -1,77 +1,77 @@
rmapi package
rmapy package
=============
Submodules
----------
rmapi.api module
rmapy.api module
----------------
.. automodule:: rmapi.api
.. automodule:: rmapy.api
:members:
:undoc-members:
:show-inheritance:
rmapi.collections module
rmapy.collections module
------------------------
.. automodule:: rmapi.collections
.. automodule:: rmapy.collections
:members:
:undoc-members:
:show-inheritance:
rmapi.config module
rmapy.config module
-------------------
.. automodule:: rmapi.config
.. automodule:: rmapy.config
:members:
:undoc-members:
:show-inheritance:
rmapi.const module
rmapy.const module
------------------
.. automodule:: rmapi.const
.. automodule:: rmapy.const
:members:
:undoc-members:
:show-inheritance:
rmapi.document module
rmapy.document module
---------------------
.. automodule:: rmapi.document
.. automodule:: rmapy.document
:members:
:undoc-members:
:show-inheritance:
rmapi.exceptions module
rmapy.exceptions module
-----------------------
.. automodule:: rmapi.exceptions
.. automodule:: rmapy.exceptions
:members:
:undoc-members:
:show-inheritance:
rmapi.folder module
rmapy.folder module
-------------------
.. automodule:: rmapi.folder
.. automodule:: rmapy.folder
:members:
:undoc-members:
:show-inheritance:
rmapi.meta module
rmapy.meta module
-----------------
.. automodule:: rmapi.meta
.. automodule:: rmapy.meta
:members:
:undoc-members:
:show-inheritance:
rmapi.types module
rmapy.types module
------------------
.. automodule:: rmapi.types
.. automodule:: rmapy.types
:members:
:undoc-members:
:show-inheritance:
@@ -80,7 +80,7 @@ rmapi.types module
Module contents
---------------
.. automodule:: rmapi
.. automodule:: rmapy
:members:
:undoc-members:
:show-inheritance: