pytolino 1.0__tar.gz → 1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytolino-1.0/src/pytolino.egg-info → pytolino-1.1}/PKG-INFO +3 -1
- {pytolino-1.0 → pytolino-1.1}/README.rst +2 -0
- {pytolino-1.0 → pytolino-1.1}/pyproject.toml +1 -1
- {pytolino-1.0 → pytolino-1.1}/src/pytolino/tolino_cloud.py +40 -0
- {pytolino-1.0 → pytolino-1.1/src/pytolino.egg-info}/PKG-INFO +3 -1
- {pytolino-1.0 → pytolino-1.1}/tests/test_tolino_cloud.py +22 -1
- {pytolino-1.0 → pytolino-1.1}/LICENSE +0 -0
- {pytolino-1.0 → pytolino-1.1}/MANIFEST.in +0 -0
- {pytolino-1.0 → pytolino-1.1}/setup.cfg +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino/__init__.py +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino/servers_settings.ini +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino.egg-info/SOURCES.txt +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino.egg-info/dependency_links.txt +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino.egg-info/requires.txt +0 -0
- {pytolino-1.0 → pytolino-1.1}/src/pytolino.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -62,6 +62,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
62
62
|
ebook_id = client.upload(EPUB_FILE_PATH) # return a unique id that can be used for reference
|
|
63
63
|
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
|
|
64
64
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
65
|
+
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
65
66
|
client.logout()
|
|
66
67
|
|
|
67
68
|
|
|
@@ -85,6 +86,7 @@ Features
|
|
|
85
86
|
* upload ebook
|
|
86
87
|
* delete ebook from the cloud
|
|
87
88
|
* add a book to a collection
|
|
89
|
+
* download inventory
|
|
88
90
|
* more to come...
|
|
89
91
|
|
|
90
92
|
|
|
@@ -36,6 +36,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
36
36
|
ebook_id = client.upload(EPUB_FILE_PATH) # return a unique id that can be used for reference
|
|
37
37
|
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
|
|
38
38
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
39
|
+
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
39
40
|
client.logout()
|
|
40
41
|
|
|
41
42
|
|
|
@@ -59,6 +60,7 @@ Features
|
|
|
59
60
|
* upload ebook
|
|
60
61
|
* delete ebook from the cloud
|
|
61
62
|
* add a book to a collection
|
|
63
|
+
* download inventory
|
|
62
64
|
* more to come...
|
|
63
65
|
|
|
64
66
|
|
|
@@ -288,6 +288,46 @@ class Client(object):
|
|
|
288
288
|
raise PytolinoException(
|
|
289
289
|
f'unregister {device_id} failed: reason unknown.')
|
|
290
290
|
|
|
291
|
+
def get_inventory(self):
|
|
292
|
+
"""download a list of the books on the cloud and their information
|
|
293
|
+
:returns: list of dict describing the book, with a epubMetaData dict
|
|
294
|
+
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
host_response = self.session.get(
|
|
298
|
+
self.server_settings['inventory_url'],
|
|
299
|
+
params={'strip': 'true'},
|
|
300
|
+
headers={
|
|
301
|
+
't_auth_token': self.access_token,
|
|
302
|
+
'hardware_id': self.hardware_id,
|
|
303
|
+
'reseller_id': self.server_settings['partner_id'],
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
self._log_requests(host_response)
|
|
308
|
+
if host_response.status_code != 200:
|
|
309
|
+
raise PytolinoException('invetory request failed')
|
|
310
|
+
|
|
311
|
+
try:
|
|
312
|
+
j = host_response.json()
|
|
313
|
+
except requests.JSONDecodeError:
|
|
314
|
+
raise PytolinoException(
|
|
315
|
+
'inventory list request failed because of json error.'
|
|
316
|
+
)
|
|
317
|
+
else:
|
|
318
|
+
try:
|
|
319
|
+
publication_inventory = j['PublicationInventory']
|
|
320
|
+
uploaded_ebooks = publication_inventory['edata']
|
|
321
|
+
purchased_ebook = publication_inventory['ebook']
|
|
322
|
+
except KeyError:
|
|
323
|
+
raise PytolinoException(
|
|
324
|
+
'inventory list request failed because',
|
|
325
|
+
'of key error in json.',
|
|
326
|
+
)
|
|
327
|
+
else:
|
|
328
|
+
inventory = uploaded_ebooks + purchased_ebook
|
|
329
|
+
return inventory
|
|
330
|
+
|
|
291
331
|
def add_to_collection(self, book_id, collection_name):
|
|
292
332
|
"""add a book to a collection on the cloud
|
|
293
333
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytolino
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1
|
|
4
4
|
Summary: client for tolino cloud
|
|
5
5
|
Author: Imam Usmani
|
|
6
6
|
Project-URL: Source Code, https://github.com/ImamAzim/pytolino
|
|
@@ -62,6 +62,7 @@ You can then upload, add to a collection or delete ebook on your cloud:
|
|
|
62
62
|
ebook_id = client.upload(EPUB_FILE_PATH) # return a unique id that can be used for reference
|
|
63
63
|
client.add_collection(epub_id, 'science fiction') # add the previous book to the collection science-fiction
|
|
64
64
|
client.delete_ebook(epub_id) # delete the previousely uploaded ebook
|
|
65
|
+
inventory = client.get_inventory() # get a list of all the books on the cloud and their metadata
|
|
65
66
|
client.logout()
|
|
66
67
|
|
|
67
68
|
|
|
@@ -85,6 +86,7 @@ Features
|
|
|
85
86
|
* upload ebook
|
|
86
87
|
* delete ebook from the cloud
|
|
87
88
|
* add a book to a collection
|
|
89
|
+
* download inventory
|
|
88
90
|
* more to come...
|
|
89
91
|
|
|
90
92
|
|
|
@@ -160,5 +160,26 @@ def delete_test():
|
|
|
160
160
|
client.logout()
|
|
161
161
|
|
|
162
162
|
|
|
163
|
+
def inventory_test():
|
|
164
|
+
|
|
165
|
+
username, password = get_credentials()
|
|
166
|
+
client = Client()
|
|
167
|
+
client.login(username, password)
|
|
168
|
+
inventory = client.get_inventory()
|
|
169
|
+
client.logout()
|
|
170
|
+
print(inventory[0].keys())
|
|
171
|
+
metadata = inventory[0]['epubMetaData']
|
|
172
|
+
print(metadata.keys())
|
|
173
|
+
|
|
174
|
+
def delete_test():
|
|
175
|
+
|
|
176
|
+
with open(EPUB_ID_PATH, 'r') as myfile:
|
|
177
|
+
epub_id = myfile.read()
|
|
178
|
+
|
|
179
|
+
username, password = get_credentials()
|
|
180
|
+
client = Client()
|
|
181
|
+
client.login(username, password)
|
|
182
|
+
client.delete_ebook(epub_id)
|
|
183
|
+
client.logout()
|
|
163
184
|
if __name__ == '__main__':
|
|
164
|
-
|
|
185
|
+
inventory_test()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|