Package pysmug :: Module methods
[hide private]
[frames] | no frames]

Source Code for Module pysmug.methods

  1  # Copyright (c) 2008 Brian Zimmer <bzimmer@ziclix.com> 
  2  # 
  3  # Permission is hereby granted, free of charge, to any person obtaining a copy of 
  4  # this software and associated documentation files (the "Software"), to deal in 
  5  # the Software without restriction, including without limitation the rights to 
  6  # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
  7  # of the Software, and to permit persons to whom the Software is furnished to do 
  8  # so, subject to the following conditions: 
  9  # 
 10  # The above copyright notice and this permission notice shall be included in all 
 11  # copies or substantial portions of the Software. 
 12  # 
 13  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 14  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 15  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 16  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 17  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 18  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
 19  # SOFTWARE. 
 20   
 21  """This module provides some lower-level metadata used to communicate with the 
 22  SmugMug API. 
 23  """ 
 24   
25 -def _smugbool(value):
26 """Formats the value into an appropriate boolean representation for SmugMug. 27 The SmugMug API will accept boolean values as either C{true|false} or C{1|0} so 28 this function accepts both strings and boolean/integer Python values and returns 29 the appropriate representation for the API. There is no corresponding mapping 30 for inbound data. 31 """ 32 if value is None: 33 return value 34 if isinstance(value, str): 35 return value.lower() 36 return int(value)
37 38 apikeys = dict((x.lower(), (x, f)) for x, f in ( 39 ("APIKey", None), 40 ("AlbumKey", None), 41 ("EmailAddress", None), 42 ("FileName", None), 43 ("Heavy", _smugbool), 44 ("ImageKey", None), 45 ("PasswordHash", None), 46 ("Pretty", _smugbool), 47 ("Strict", _smugbool), 48 )) 49 """A mapping between lower-cased names and their SmugMug API case and formatting 50 function. This is a one-way mapping usually used to format a Python C{bool} 51 into its numeric value usable by the SmugMug API. 52 """ 53 54 methods = set( 55 ['smugmug.albums.applyWatermark', 56 'smugmug.albums.changeSettings', 57 'smugmug.albums.create', 58 'smugmug.albums.delete', 59 'smugmug.albums.get', 60 'smugmug.albums.getInfo', 61 'smugmug.albums.getStats', 62 'smugmug.albums.reSort', 63 'smugmug.albums.removeWatermark', 64 'smugmug.albumtemplates.changeSettings', 65 'smugmug.albumtemplates.create', 66 'smugmug.albumtemplates.delete', 67 'smugmug.albumtemplates.get', 68 'smugmug.categories.create', 69 'smugmug.categories.delete', 70 'smugmug.categories.get', 71 'smugmug.categories.rename', 72 'smugmug.communities.get', 73 'smugmug.communities.getAvailable', 74 'smugmug.communities.join', 75 'smugmug.communities.leave', 76 'smugmug.communities.leaveAll', 77 'smugmug.family.add', 78 'smugmug.family.get', 79 'smugmug.family.remove', 80 'smugmug.family.removeAll', 81 'smugmug.friends.add', 82 'smugmug.friends.get', 83 'smugmug.friends.remove', 84 'smugmug.friends.removeAll', 85 'smugmug.images.applyWatermark', 86 'smugmug.images.changePosition', 87 'smugmug.images.changeSettings', 88 'smugmug.images.crop', 89 'smugmug.images.delete', 90 'smugmug.images.get', 91 'smugmug.images.getEXIF', 92 'smugmug.images.getInfo', 93 'smugmug.images.getStats', 94 'smugmug.images.getURLs', 95 'smugmug.images.pricing', 96 'smugmug.images.removeWatermark', 97 'smugmug.images.rotate', 98 #'smugmug.images.upload', 99 'smugmug.images.uploadFromURL', 100 'smugmug.images.zoomThumbnail', 101 'smugmug.login.anonymously', 102 'smugmug.login.withHash', 103 'smugmug.login.withPassword', 104 'smugmug.orders.get', 105 'smugmug.orders.ship', 106 'smugmug.propricing.getAlbum', 107 'smugmug.propricing.getImage', 108 'smugmug.propricing.getPortfolio', 109 'smugmug.propricing.setAlbum', 110 'smugmug.propricing.setImage', 111 'smugmug.propricing.setPortfolio', 112 'smugmug.sharegroups.addAlbum', 113 'smugmug.sharegroups.changeSettings', 114 'smugmug.sharegroups.create', 115 'smugmug.sharegroups.delete', 116 'smugmug.sharegroups.get', 117 'smugmug.sharegroups.getInfo', 118 'smugmug.sharegroups.removeAlbum', 119 'smugmug.styles.getTemplates', 120 'smugmug.subcategories.create', 121 'smugmug.subcategories.delete', 122 'smugmug.subcategories.get', 123 'smugmug.subcategories.getAll', 124 'smugmug.subcategories.rename', 125 'smugmug.themes.get', 126 'smugmug.users.getDisplayName', 127 'smugmug.users.getTransferStats', 128 'smugmug.users.getTree', 129 'smugmug.watermarks.changeSettings', 130 'smugmug.watermarks.createnew', 131 'smugmug.watermarks.delete', 132 'smugmug.watermarks.get', 133 'smugmug.watermarks.getInfo' 134 ]) 135 """Valid methods for the SmugMug (+ extended) API. 136 """ 137