diff --git a/openphoto/api_album.py b/openphoto/api_album.py index 819a947..f556a52 100644 --- a/openphoto/api_album.py +++ b/openphoto/api_album.py @@ -46,7 +46,7 @@ class ApiAlbum: return album def view(self, album, **kwds): - """ + """ View an album's contents. Returns the requested album object. """ diff --git a/openphoto/api_photo.py b/openphoto/api_photo.py index e5c366b..097cc31 100644 --- a/openphoto/api_photo.py +++ b/openphoto/api_photo.py @@ -60,7 +60,7 @@ class ApiPhoto: raise NotImplementedError() def update(self, photo, **kwds): - """ + """ Update a photo with the specified parameters. Returns the updated photo object """ @@ -70,8 +70,8 @@ class ApiPhoto: return photo def view(self, photo, **kwds): - """ - Used to view the photo at a particular size. + """ + Used to view the photo at a particular size. Returns the requested photo object """ if not isinstance(photo, Photo): @@ -90,7 +90,7 @@ class ApiPhoto: """ Base64-encodes and uploads the specified file """ with open(photo_file, "rb") as f: encoded_photo = base64.b64encode(f.read()) - result = self._client.post("/photo/upload.json", photo=encoded_photo, + result = self._client.post("/photo/upload.json", photo=encoded_photo, **kwds)["result"] return Photo(self._client, result) @@ -98,9 +98,9 @@ class ApiPhoto: raise NotImplementedError() def next_previous(self, photo, **kwds): - """ + """ Returns a dict containing the next and previous photo lists - (there may be more than one next/previous photo returned). + (there may be more than one next/previous photo returned). """ if not isinstance(photo, Photo): photo = Photo(self._client, {"id": photo}) @@ -108,7 +108,7 @@ class ApiPhoto: def transform(self, photo, **kwds): """ - Performs transformation specified in **kwds + Performs transformation specified in **kwds Example: transform(photo, rotate=90) """ if not isinstance(photo, Photo): diff --git a/openphoto/objects.py b/openphoto/objects.py index 235c96f..4d28dc5 100644 --- a/openphoto/objects.py +++ b/openphoto/objects.py @@ -17,10 +17,10 @@ class OpenPhotoObject: if key.startswith("_"): raise ValueError("Illegal attribute: %s" % key) setattr(self, key, value) - + def _replace_fields(self, json_dict): - """ - Delete this object's attributes, and replace with + """ + Delete this object's attributes, and replace with those in json_dict. """ for key in self._json_dict.keys(): @@ -54,7 +54,7 @@ class Photo(OpenPhotoObject): def edit(self, **kwds): """ Returns an HTML form to edit the photo """ - result = self._openphoto.get("/photo/%s/edit.json" % self.id, + result = self._openphoto.get("/photo/%s/edit.json" % self.id, **kwds)["result"] return result["markup"] @@ -66,16 +66,16 @@ class Photo(OpenPhotoObject): def update(self, **kwds): """ Update this photo with the specified parameters """ - new_dict = self._openphoto.post("/photo/%s/update.json" % self.id, + new_dict = self._openphoto.post("/photo/%s/update.json" % self.id, **kwds)["result"] self._replace_fields(new_dict) def view(self, **kwds): - """ - Used to view the photo at a particular size. + """ + Used to view the photo at a particular size. Updates the photo's fields with the response. """ - new_dict = self._openphoto.get("/photo/%s/view.json" % self.id, + new_dict = self._openphoto.get("/photo/%s/view.json" % self.id, **kwds)["result"] self._replace_fields(new_dict) @@ -83,11 +83,11 @@ class Photo(OpenPhotoObject): raise NotImplementedError() def next_previous(self, **kwds): - """ - Returns a dict containing the next and previous photo lists - (there may be more than one next/previous photo returned). """ - result = self._openphoto.get("/photo/%s/nextprevious.json" % self.id, + Returns a dict containing the next and previous photo lists + (there may be more than one next/previous photo returned). + """ + result = self._openphoto.get("/photo/%s/nextprevious.json" % self.id, **kwds)["result"] value = {} if "next" in result: @@ -137,7 +137,7 @@ class Tag(OpenPhotoObject): def update(self, **kwds): """ Update this tag with the specified parameters """ - new_dict = self._openphoto.post("/tag/%s/update.json" % quote(self.id), + new_dict = self._openphoto.post("/tag/%s/update.json" % quote(self.id), **kwds)["result"] self._replace_fields(new_dict) @@ -173,13 +173,13 @@ class Album(OpenPhotoObject): def add_photos(self, **kwds): raise NotImplementedError() - + def remove_photos(self, **kwds): raise NotImplementedError() def update(self, **kwds): """ Update this album with the specified parameters """ - new_dict = self._openphoto.post("/album/%s/update.json" % self.id, + new_dict = self._openphoto.post("/album/%s/update.json" % self.id, **kwds)["result"] # APIv1 doesn't return the updated album (frontend issue #937) @@ -188,13 +188,13 @@ class Album(OpenPhotoObject): self._replace_fields(new_dict) self._update_fields_with_objects() - + def view(self, **kwds): - """ + """ Requests the full contents of the album. Updates the album's fields with the response. """ - result = self._openphoto.get("/album/%s/view.json" % self.id, + result = self._openphoto.get("/album/%s/view.json" % self.id, **kwds)["result"] self._replace_fields(result) self._update_fields_with_objects()