├── LICENSE ├── README.markdown ├── delicious.py ├── index.html └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | Python-Delicious is released under the following license derived from the 2 | BSD license: 3 | 4 | Copyright (c) 2005, Paul Mucur 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of Paul Mucur nor the names of other 17 | contributors to this source code may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Python-Delicious 2 | ================ 3 | 4 | Python module to access del.icio.us via its API. 5 | 6 | Copyright 2005-2008 by Paul Mucur 7 | BSD License 8 | 9 | To install: 10 | 11 | python setup.py install 12 | 13 | For usage information and documentation, see index.html. 14 | 15 | Contributors 16 | ------------ 17 | 18 | * [Morgan Craft](https://github.com/mgan59) 19 | -------------------------------------------------------------------------------- /delicious.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Python-Delicious 3 | 4 | Python module for access to del.icio.us via its API. 5 | 6 | Recommended: Python 2.3 or later (untested on previous versions) 7 | """ 8 | 9 | __version__ = "pre-1.0" 10 | #__version__ = "1.0" 11 | __license__ = "BSD" 12 | __copyright__ = "Copyright 2005-2008, Paul Mucur" 13 | __author__ = "Paul Mucur " 14 | 15 | #TODO: 16 | # Should text be properly escaped for XML? Or that not this module's 17 | # responsibility? 18 | # Create test suite 19 | # Gzip support - but the API does not yet support it 20 | # Use Etags and Last-Modified to make requests more efficient - but the API 21 | # does not yet support it 22 | 23 | _debug = 0 24 | 25 | # The user agent string sent to del.icio.us when making requests. If you are 26 | # using this module in your own application, you should probably change this. 27 | USER_AGENT = "Python-Delicious/%s +http://github.com/mudge/python-delicious" % __version__ 28 | 29 | import urllib 30 | import urllib2 31 | import sys 32 | import re 33 | import time 34 | from xml.dom import minidom 35 | try: 36 | StringTypes = basestring 37 | except: 38 | try: 39 | # Python 2.2 does not have basestring 40 | from types import StringTypes 41 | except: 42 | # Python 2.0 and 2.1 do not have StringTypes 43 | from types import StringType, UnicodeType 44 | StringTypes = None 45 | try: 46 | ListType = list 47 | TupleType = tuple 48 | except: 49 | from types import ListType, TupleType 50 | 51 | # Taken from Mark Pilgrim's amazing Universal Feed Parser 52 | # 53 | try: 54 | UserDict = dict 55 | except NameError: 56 | from UserDict import UserDict 57 | try: 58 | import datetime 59 | except: 60 | datetime = None 61 | 62 | 63 | # The URL of the del.icio.us API as it will be changing shortly. 64 | DELICIOUS_API = "https://api.del.icio.us/v1" 65 | 66 | def open(username, password): 67 | """Open a connection to a del.icio.us account""" 68 | return DeliciousAccount(username, password) 69 | 70 | def connect(username, password): 71 | """Open a connection to a del.icio.us account""" 72 | return open(username, password) 73 | 74 | 75 | # Custom exceptions 76 | 77 | class DeliciousError(Exception): 78 | """Error in the Python-Delicious module""" 79 | pass 80 | 81 | class ThrottleError(DeliciousError): 82 | """Error caused by del.icio.us throttling requests""" 83 | def __init__(self, url, message): 84 | self.url = url 85 | self.message = message 86 | def __str__(self): 87 | return "%s: %s" % (self.url, self.message) 88 | 89 | class AddError(DeliciousError): 90 | """Error adding a post to del.icio.us""" 91 | pass 92 | 93 | class DeleteError(DeliciousError): 94 | """Error deleting a post from del.icio.us""" 95 | pass 96 | 97 | class BundleError(DeliciousError): 98 | """Error bundling tags on del.icio.us""" 99 | pass 100 | 101 | class DeleteBundleError(DeliciousError): 102 | """Error deleting a bundle from del.icio.us""" 103 | pass 104 | 105 | class RenameTagError(DeliciousError): 106 | """Error renaming a tag in del.icio.us""" 107 | pass 108 | 109 | class DateParamsError(DeliciousError): 110 | '''Date params error''' 111 | pass 112 | 113 | class DeliciousAccount(UserDict): 114 | """A del.icio.us account""" 115 | 116 | # Used to track whether all posts have been downloaded yet. 117 | __allposts = 0 118 | __postschanged = 0 119 | 120 | # Time of last request so that the one second limit can be enforced. 121 | __lastrequest = None 122 | 123 | # Special methods 124 | 125 | def __init__(self, username, password): 126 | UserDict.__init__(self) 127 | 128 | # Authenticate the URL opener so that it can access del.icio.us 129 | if _debug: 130 | sys.stderr.write("Initialising DeliciousAccount object.\n") 131 | auth_handler = urllib2.HTTPBasicAuthHandler() 132 | auth_handler.add_password("del.icio.us API", "https://api.del.icio.us/", \ 133 | username, password) 134 | opener = urllib2.build_opener(auth_handler) 135 | opener.addheaders = [("User-agent", USER_AGENT)] 136 | urllib2.install_opener(opener) 137 | if _debug: 138 | sys.stderr.write("URL opener with HTTP authenticiation installed globally.\n") 139 | self["lastupdate"] = self.lastupdate() 140 | self["lastupdate_parsed"] = time.strptime(self["lastupdate"], \ 141 | "%Y-%m-%dT%H:%M:%SZ") 142 | if _debug: 143 | sys.stderr.write("Time of last update loaded into class dictionary.\n") 144 | 145 | def __getitem__(self, key): 146 | try: 147 | return UserDict.__getitem__(self, key) 148 | except KeyError: 149 | if key == "tags": 150 | return self.tags() 151 | elif key == "dates": 152 | return self.dates() 153 | elif key == "posts": 154 | return self.posts() 155 | elif key == "bundles": 156 | return self.bundles() 157 | 158 | def __setitem__(self, key, value): 159 | if key == "posts": 160 | if _debug: 161 | sys.stderr.write("The value of posts has been changed.\n") 162 | self.__postschanged = 1 163 | return UserDict.__setitem__(self, key, value) 164 | 165 | 166 | def __request(self, url): 167 | 168 | # Make sure that it has been at least 1 second since the last 169 | # request was made. If not, halt execution for approximately one 170 | # seconds. 171 | if self.__lastrequest and (time.time() - self.__lastrequest) < 2: 172 | if _debug: 173 | sys.stderr.write("It has been less than two seconds since the last request; halting execution for one second.\n") 174 | time.sleep(1) 175 | if _debug and self.__lastrequest: 176 | sys.stderr.write("The delay between requests was %d.\n" % (time.time() - self.__lastrequest)) 177 | self.__lastrequest = time.time() 178 | if _debug: 179 | sys.stderr.write("Opening %s.\n" % url) 180 | xml = urllib2.urlopen(url) 181 | self["headers"] = {} 182 | for header in xml.headers.headers: 183 | (name, value) = header.split(": ") 184 | self["headers"][name.lower()] = value[:-2] 185 | if xml.headers.status == "503": 186 | raise ThrottleError(url, \ 187 | "503 HTTP status code returned by del.icio.us") 188 | if _debug: 189 | sys.stderr.write("%s opened successfully.\n" % url) 190 | return minidom.parseString(xml.read()) 191 | 192 | 193 | # Methods to fetch del.icio.us content 194 | 195 | def lastupdate(self): 196 | """Return the last time that the del.icio.us account was updated.""" 197 | return self.__request("%s/posts/update" % \ 198 | DELICIOUS_API).firstChild.getAttribute("time") 199 | 200 | def posts(self, tag="", date="", todt="", fromdt="", count=0): 201 | """Return del.icio.us bookmarks as a list of dictionaries. 202 | 203 | This should be used without arguments as rarely as possible by 204 | combining it with the lastupdate attribute to only get all posts when 205 | there is new content as it places a large load on the del.icio.us 206 | servers. 207 | 208 | """ 209 | query = {} 210 | 211 | ## if a date is passed then a ranged set of date params CANNOT be passed 212 | if date and (todt or fromdt): 213 | raise DateParamsError 214 | 215 | if not count and not date and not todt and not fromdt and not tag: 216 | path = "all" 217 | 218 | # If attempting to load all of the posts from del.icio.us, and 219 | # a previous download has been done, check to see if there has 220 | # been an update; if not, then just return the posts stored 221 | # inside the class. 222 | if _debug: 223 | sys.stderr.write("Checking to see if a previous download has been made.\n") 224 | if not self.__postschanged and self.__allposts and \ 225 | self.lastupdate() == self["lastupdate"]: 226 | if _debug: 227 | sys.stderr.write("It has; returning old posts instead.\n") 228 | return self["posts"] 229 | elif not self.__allposts: 230 | if _debug: 231 | sys.stderr.write("Making note of request for all posts.\n") 232 | self.__allposts = 1 233 | elif date: 234 | path = "get" 235 | elif todt or fromdt: 236 | path = "all" 237 | else: 238 | path = "recent" 239 | if count: 240 | query["count"] = count 241 | if tag: 242 | query["tag"] = tag 243 | 244 | ##todt 245 | if todt and (isinstance(todt, ListType) or isinstance(todt, TupleType)): 246 | query["todt"] = "-".join([str(x) for x in todt[:3]]) 247 | elif todt and (todt and isinstance(todt, datetime.datetime) or \ 248 | isinstance(todt, datetime.date)): 249 | query["todt"] = "-".join([str(todt.year), str(todt.month), str(todt.day)]) 250 | elif todt: 251 | query["todt"] = todt 252 | 253 | ## fromdt 254 | if fromdt and (isinstance(fromdt, ListType) or isinstance(fromdt, TupleType)): 255 | query["fromdt"] = "-".join([str(x) for x in fromdt[:3]]) 256 | elif fromdt and (fromdt and isinstance(fromdt, datetime.datetime) or \ 257 | isinstance(fromdt, datetime.date)): 258 | query["fromdt"] = "-".join([str(fromdt.year), str(fromdt.month), str(fromdt.day)]) 259 | elif fromdt: 260 | query["fromdt"] = fromdt 261 | 262 | if date and (isinstance(date, ListType) or isinstance(date, TupleType)): 263 | query["dt"] = "-".join([str(x) for x in date[:3]]) 264 | elif date and (datetime and isinstance(date, datetime.datetime) or \ 265 | isinstance(date, datetime.date)): 266 | query["dt"] = "-".join([str(date.year), str(date.month), str(date.day)]) 267 | elif date: 268 | query["dt"] = date 269 | 270 | postsxml = self.__request("%s/posts/%s?%s" % (DELICIOUS_API, path, \ 271 | urllib.urlencode(query))).getElementsByTagName("post") 272 | posts = [] 273 | if _debug: 274 | sys.stderr.write("Parsing posts XML into a list of dictionaries.\n") 275 | 276 | # For each post, extract every attribute (splitting tags into sub-lists) 277 | # and insert as a dictionary into the `posts` list. 278 | for post in postsxml: 279 | postdict = {} 280 | for (name, value) in post.attributes.items(): 281 | if name == u"tag": 282 | name = u"tags" 283 | value = value.split(" ") 284 | if name == u"time": 285 | postdict[u"time_parsed"] = time.strptime(value, "%Y-%m-%dT%H:%M:%SZ") 286 | postdict[name] = value 287 | if self.has_key("posts") and isinstance(self["posts"], ListType) \ 288 | and postdict not in self["posts"]: 289 | self["posts"].append(postdict) 290 | posts.append(postdict) 291 | if _debug: 292 | sys.stderr.write("Inserting posts list into class attribute.\n") 293 | if not self.has_key("posts"): 294 | self["posts"] = posts 295 | if _debug: 296 | sys.stderr.write("Resetting marker so module doesn't think posts has been changed.\n") 297 | self.__postschanged = 0 298 | return posts 299 | 300 | def tags(self): 301 | """Return a dictionary of tags with the number of posts in each one""" 302 | tagsxml = self.__request("%s/tags/get?" % \ 303 | DELICIOUS_API).getElementsByTagName("tag") 304 | tags = [] 305 | if _debug: 306 | sys.stderr.write("Parsing tags XML into a list of dictionaries.\n") 307 | for tag in tagsxml: 308 | tagdict = {} 309 | for (name, value) in tag.attributes.items(): 310 | if name == u"tag": 311 | name = u"name" 312 | elif name == u"count": 313 | value = int(value) 314 | tagdict[name] = value 315 | if self.has_key("tags") and isinstance(self["tags"], ListType) \ 316 | and tagdict not in self["tags"]: 317 | self["tags"].append(tagdict) 318 | tags.append(tagdict) 319 | if _debug: 320 | sys.stderr.write("Inserting tags list into class attribute.\n") 321 | if not self.has_key("tags"): 322 | self["tags"] = tags 323 | return tags 324 | 325 | def bundles(self): 326 | """Return a dictionary of all bundles""" 327 | bundlesxml = self.__request("%s/tags/bundles/all" % \ 328 | DELICIOUS_API).getElementsByTagName("bundle") 329 | bundles = [] 330 | if _debug: 331 | sys.stderr.write("Parsing bundles XML into a list of dictionaries.\n") 332 | for bundle in bundlesxml: 333 | bundledict = {} 334 | for (name, value) in bundle.attributes.items(): 335 | bundledict[name] = value 336 | if self.has_key("bundles") and isinstance(self["bundles"], ListType) \ 337 | and bundledict not in self["bundles"]: 338 | self["bundles"].append(bundledict) 339 | bundles.append(bundledict) 340 | if _debug: 341 | sys.stderr.write("Inserting bundles list into class attribute.\n") 342 | if not self.has_key("bundles"): 343 | self["bundles"] = bundles 344 | return bundles 345 | 346 | def dates(self, tag=""): 347 | """Return a dictionary of dates with the number of posts at each date""" 348 | if tag: 349 | query = urllib.urlencode({"tag":tag}) 350 | else: 351 | query = "" 352 | datesxml = self.__request("%s/posts/dates?%s" % \ 353 | (DELICIOUS_API, query)).getElementsByTagName("date") 354 | dates = [] 355 | if _debug: 356 | sys.stderr.write("Parsing dates XML into a list of dictionaries.\n") 357 | for date in datesxml: 358 | datedict = {} 359 | for (name, value) in date.attributes.items(): 360 | if name == u"date": 361 | datedict[u"date_parsed"] = time.strptime(value, "%Y-%m-%d") 362 | elif name == u"count": 363 | value = int(value) 364 | datedict[name] = value 365 | if self.has_key("dates") and isinstance(self["dates"], ListType) \ 366 | and datedict not in self["dates"]: 367 | self["dates"].append(datedict) 368 | dates.append(datedict) 369 | if _debug: 370 | sys.stderr.write("Inserting dates list into class attribute.\n") 371 | if not self.has_key("dates"): 372 | self["dates"] = dates 373 | return dates 374 | 375 | 376 | # Methods to modify del.icio.us content 377 | 378 | def add(self, url, description, extended="", tags=(), date=""): 379 | """Add a new post to del.icio.us""" 380 | query = {} 381 | query["url"] = url 382 | query ["description"] = description 383 | if extended: 384 | query["extended"] = extended 385 | if tags and (isinstance(tags, TupleType) or isinstance(tags, ListType)): 386 | query["tags"] = " ".join(tags) 387 | elif tags and (StringTypes and isinstance(tags, StringTypes)) or \ 388 | (not StringTypes and (isinstance(tags, StringType) or \ 389 | isinstance(tags, UnicodeType))): 390 | query["tags"] = tags 391 | 392 | # This is a rather rudimentary way of parsing date strings into 393 | # ISO8601 dates: if the date string is shorter than the required 394 | # 20 characters then it is assumed that it is a partial date 395 | # such as "2005-3-31" or "2005-3-31T20:00" and it is split into a 396 | # list along non-numerals. Empty elements are then removed 397 | # and then this is passed to the tuple/list case where 398 | # the tuple/list is padded with necessary 0s and then formatted 399 | # into an ISO8601 date string. This does not take into account 400 | # time zones. 401 | if date and (StringTypes and isinstance(tags, StringTypes)) or \ 402 | (not StringTypes and (isinstance(tags, StringType) or \ 403 | isinstance(tags, UnicodeType))) and len(date) < 20: 404 | date = re.split("\D", date) 405 | while '' in date: 406 | date.remove('') 407 | if date and (isinstance(date, ListType) or isinstance(date, TupleType)): 408 | date = list(date) 409 | if len(date) > 2 and len(date) < 6: 410 | for i in range(6 - len(date)): 411 | date.append(0) 412 | query["dt"] = "%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ" % tuple(date) 413 | elif date and (datetime and (isinstance(date, datetime.datetime) \ 414 | or isinstance(date, datetime.date))): 415 | query["dt"] = "%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ" % date.utctimetuple()[:6] 416 | elif date: 417 | query["dt"] = date 418 | try: 419 | response = self.__request("%s/posts/add?%s" % (DELICIOUS_API, \ 420 | urllib.urlencode(query))) 421 | if response.firstChild.getAttribute("code") != u"done": 422 | raise AddError 423 | if _debug: 424 | sys.stderr.write("Post, %s (%s), added to del.icio.us\n" \ 425 | % (description, url)) 426 | except: 427 | if _debug: 428 | sys.stderr.write("Unable to add post, %s (%s), to del.icio.us\n" \ 429 | % (description, url)) 430 | 431 | def bundle(self, bundle, tags): 432 | """Bundle a set of tags together""" 433 | query = {} 434 | query["bundle"] = bundle 435 | if tags and (isinstance(tags, TupleType) or isinstance(tags, ListType)): 436 | query["tags"] = " ".join(tags) 437 | elif tags and isinstance(tags, StringTypes): 438 | query["tags"] = tags 439 | try: 440 | response = self.__request("%s/tags/bundles/set?%s" % (DELICIOUS_API, \ 441 | urllib.urlencode(query))) 442 | if response.firstChild.getAttribute("code") != u"done": 443 | raise BundleError 444 | if _debug: 445 | sys.stderr.write("Tags, %s, bundled into %s.\n" \ 446 | % (repr(tags), bundle)) 447 | except: 448 | if _debug: 449 | sys.stderr.write("Unable to bundle tags, %s, into %s to del.icio.us\n" \ 450 | % (repr(tags), bundle)) 451 | 452 | def delete(self, url): 453 | """Delete post from del.icio.us by its URL""" 454 | try: 455 | response = self.__request("%s/posts/delete?%s" % (DELICIOUS_API, \ 456 | urllib.urlencode({"url":url}))) 457 | if response.firstChild.getAttribute("code") != u"done": 458 | raise DeleteError 459 | if _debug: 460 | sys.stderr.write("Post, %s, deleted from del.icio.us\n" \ 461 | % url) 462 | except: 463 | if _debug: 464 | sys.stderr.write("Unable to delete post, %s, from del.icio.us\n" \ 465 | % url) 466 | 467 | def delete_bundle(self, name): 468 | """Delete bundle from del.icio.us by its name""" 469 | try: 470 | response = self.__request("%s/tags/bundles/delete?%s" % (DELICIOUS_API, \ 471 | urllib.urlencode({"bundle":name}))) 472 | if response.firstChild.getAttribute("code") != u"done": 473 | raise DeleteBundleError 474 | if _debug: 475 | sys.stderr.write("Bundle, %s, deleted from del.icio.us\n" \ 476 | % name) 477 | except: 478 | if _debug: 479 | sys.stderr.write("Unable to delete bundle, %s, from del.icio.us\n" \ 480 | % name) 481 | 482 | def rename_tag(self, old, new): 483 | """Rename a tag""" 484 | query = {"old":old, "new":new} 485 | try: 486 | response = self.__request("%s/tags/rename?%s" % (DELICIOUS_API, \ 487 | urllib.urlencode(query))) 488 | if response.firstChild.getAttribute("code") != u"done": 489 | raise RenameTagError 490 | if _debug: 491 | sys.stderr.write("Tag, %s, renamed to %s\n" \ 492 | % (old, new)) 493 | except: 494 | if _debug: 495 | sys.stderr.write("Unable to rename %s tag to %s in del.icio.us\n" \ 496 | % (old, new)) 497 | 498 | if __name__ == "__main__": 499 | if sys.argv[1:][0] == '-v' or sys.argv[1:][0] == '--version': 500 | print __version__ 501 | 502 | #REVISION HISTORY 503 | #0.1 - 29/3/2005 - PEM - Initial version. 504 | #0.2 - 30/3/2005 - PEM - Now using urllib's urlencode to handle query building 505 | # and the class now extends dict (or failing that: UserDict). 506 | #0.3 - 30/3/2005 - PEM - Rewrote doc strings and improved the metaphor that the 507 | # account is a dictionary by adding posts, tags and dates to the account 508 | # object when they are called. This has the added benefit of reducing 509 | # requests to del.icio.us as one need only call posts(), dates() and tags() 510 | # once and they are stored inside the class instance until deletion. 511 | #0.4 - 30/3/2005 - PEM - Added private __request method to handle URL requests 512 | # to del.icio.us and implemented throttle detection. 513 | #0.5 - 30/3/2005 - PEM - Now implements every part of the API specification 514 | #0.6 - 30/3/2005 - PEM - Heavily vetted code to conform with PEP 8: use of 515 | # isinstance(), use of `if var` and `if not var` instead of comparison to 516 | # empty strings and changed all string delimiters to double primes for 517 | # consistency. 518 | #0.7 - 31/3/2005 - PEM - Made it so that when a fetching operation such as 519 | # posts() or tags() is used, only new posts are added to the class dictionary 520 | # in part to increase efficiency and to prevent, say, an all posts call of 521 | # posts() being overwritten by a specific request such as posts(tag="ruby") 522 | # Added more intelligent date handling for adding posts; will now attempt to 523 | # format any *reasonable* string, tuple or list into an ISO8601 date. Also 524 | # changed the command to get the lastupdate as it was convoluted. The 525 | # all posts command now checks to see if del.icio.us has been updated since 526 | # it was last called, again, this is to reduce the load on the servers and 527 | # increase speed a little. Changed the version string to a pre-1.0 release 528 | # Subversion-generated one because I am lazy. 529 | #0.8 - 1/4/2005 - PEM - Improved intelligence of posts caching: will only 530 | # re-download all posts if the posts attribute has been changed. Added 531 | # the mandatory delay between requests of at least one second. Changed the 532 | # crude string replace method to encode ampersands with a more intelligent 533 | # regular expression. 534 | #0.9 - 2/4/2005 - PEM - Now uses datetime objects when possible. 535 | #0.10 - 4/4/2005 - PEM - Uses the time module when the datetime module is 536 | # unavailable (such as versions of Python prior to 2.3). Now uses time 537 | # tuples instead of datetime objects when outputting for compatibility and 538 | # consistency. Time tuples are a new attribute: "date_parsed", with the 539 | # original string format of the date (or datetime) in "date" etc. Now stores 540 | # the headers of each request. 541 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Python-Delicious (by Mudge) 7 | 34 | 35 | 36 | 37 |

Python-Delicious

38 |

Python-Delicious is an open source Python module to access the contents of a del.icio.us account via the del.icio.us API.

39 |

Sections on This Page

40 |
    41 |
  1. Example Usage
  2. 42 |
  3. Documentation
  4. 43 |
44 |
45 |

Example Usage

46 |
>>> import delicious
 47 | >>> d = delicious.open("username", "password")
 48 | >>> d
 49 | {'lastupdate_parsed': (2005, 5, 9, 9, 49, 29, 0, 129, -1),
 50 | 	'headers': {'transfer-encoding': 'chunked', 'vary': '*',
 51 | 		'server': 'Apache/1.3.33 (Debian GNU/Linux) 
 52 | 			mod_gzip/1.3.26.1a mod_perl/1.29
 53 | 			AuthMySQL/4.3.9-2',
 54 | 		'connection': 'close',
 55 | 		'date': 'Mon, 09 May 2005 12:14:22 GMT',
 56 | 		'content-type': 'text/plain'},
 57 | 	'lastupdate': u'2005-05-09T09:49:29Z'}
 58 | >>> d["lastupdate"]
 59 | u'2005-05-09T09:49:29Z'
 60 | >>> d["lastupdate_parsed"]
 61 | (2005, 5, 9, 9, 49, 29, 0, 129, -1)
 62 | >>> d["headers"]
 63 | {'transfer-encoding': 'chunked', 'vary': '*',
 64 | 	'server': 'Apache/1.3.33 (Debian GNU/Linux) 
 65 | 		mod_gzip/1.3.26.1a mod_perl/1.29 
 66 | 		AuthMySQL/4.3.9-2',
 67 | 	'connection': 'close', 
 68 | 	'date': 'Mon, 09 May 2005 12:14:22 GMT', 
 69 | 	'content-type': 'text/plain'}
 70 | >>> d["tags"]
 71 | [{u'count': 1, u'name': u'aggregation'},
 72 | 	{u'count': 2, u'name': u'ajax'},
 73 | 	{u'count': 1, u'name': u'america'},
 74 | 	{u'count': 1, u'name': u'api'},
 75 | 	{u'count': 10, u'name': u'apple'},
 76 | 	{u'count': 2, u'name': u'art'},
 77 | 	{u'count': 1, u'name': u'atom'},
 78 | 	{u'count': 1, u'name': u'blogging'},
 79 | 	{u'count': 1, u'name': u'cartoons'}]
 80 | >>> d["tags"][:2]
 81 | [{u'count': 1, u'name': u'aggregation'},
 82 | 	{u'count': 2, u'name': u'ajax'}]
 83 | >>> d["dates"]
 84 | [{u'count': 2, u'date': u'2005-05-08', 
 85 | 		u'date_parsed': (2005, 5, 8, 0, 0, 0, 6, 128, -1)},
 86 | 	{u'count': 8, u'date': u'2005-05-07', 
 87 | 		u'date_parsed': (2005, 5, 7, 0, 0, 0, 5, 127, -1)}, 
 88 | 	{u'count': 5, u'date': u'2005-05-06', 
 89 | 		u'date_parsed': (2005, 5, 6, 0, 0, 0, 4, 126, -1)},
 90 | 	{u'count': 8, u'date': u'2005-05-05', 
 91 | 		u'date_parsed': (2005, 5, 5, 0, 0, 0, 3, 125, -1)}, 
 92 | 	{u'count': 3, u'date': u'2005-05-04', 
 93 | 		u'date_parsed': (2005, 5, 4, 0, 0, 0, 2, 124, -1)}]
 94 | >>> d["posts"][:2]
 95 | [{u'extended': u'For when I get back home', 
 96 | 		u'hash': u'5fe05afcfc229db0d6cbcb1cbdda71cf', 
 97 | 		u'description': u'Bonjour for Windows', 
 98 | 		u'tags': [u'apple', u'windows'], 
 99 | 		u'time_parsed': (2005, 5, 8, 18, 16, 1, 6, 128, -1), 
100 | 		u'href': u'http://www.apple.com/', 
101 | 		u'time': u'2005-05-08T18:16:01Z'},
102 | 	{u'hash': u'170322ad5668143742efef335a334da5',
103 | 		u'description': u'Matthew Thomas', 
104 | 		u'tags': [u'usability'], 
105 | 		u'time_parsed': (2005, 5, 7, 13, 27, 46, 5, 127, -1), 
106 | 		u'href': u'http://mpt.net.nz/', 
107 | 		u'time': u'2005-05-07T13:27:46Z'}]
108 | >>> d.posts(tag="usability")
109 | [{u'hash': u'170322ad5668143742efef335a334da5', 
110 | 		u'description': u'Matthew Thomas', 
111 | 		u'tags': [u'usability'], 
112 | 		u'time_parsed': (2005, 5, 7, 13, 27, 46, 5, 127, -1), 
113 | 		u'href': u'http://mpt.net.nz/', 
114 | 		u'time': u'2005-05-07T13:27:46Z'},
115 | 	{u'extended': u'I bookmark this because Matthew Thomas 
116 | 			(aka mpt) is working on it',
117 | 		u'hash': u'eb1242cfeed2dd9d2e1250bde26ad749', 
118 | 		u'description': u'The Launchpad Home Page', 
119 | 		u'tags': [u'usability'], 
120 | 		u'time_parsed': (2005, 5, 7, 13, 26, 45, 5, 127, -1), 
121 | 		u'href': u'https://launchpad.ubuntu.com/', 
122 | 		u'time': u'2005-05-07T13:26:45Z'}]
123 | >>> d.posts(tag="computing", count=1)
124 | [{u'hash': u'd78a1aa1a086dd475f83691febcc61ba',
125 | 	u'description': u'CSS Cheat Sheet', 
126 | 	u'tags': [u'reference', u'computing'], 
127 | 	u'time_parsed': (2005, 5, 6, 9, 41, 33, 4, 126, -1), 
128 | 	u'href': u'http://www.ilovejackdaniels.com/css/', 
129 | 	u'time': u'2005-05-06T09:41:33Z'}]
130 | >>> d.add('http://mudge.name/projects/python-delicious/',
131 | 	"Python-Delicious",
132 | 	"A Python module to access the contents of a 
133 | 		del.icio.us account via the del.icio.us API.", 
134 | 		("computing", "python"))         
135 | >>> d.add('http://mudge.name/projects/python-delicious/',
136 | 	"Python-Delicious", 
137 | 	tags=("computing", "python", "projects"))
138 | >>> d.delete("http://mudge.name/projects/python-delicious/")
139 |
140 |
141 |

Documentation

142 |

Copyright © 2005 Paul Mucur.

143 |

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

144 |
    145 |
  1. Notes on Documentation
  2. 146 |
  3. 147 | Brief Overview 148 |
      149 |
    1. What is Python-Delicious and why is it different to all the other Python modules for del.icio.us out there?
    2. 150 |
    151 |
  4. 152 |
  5. 153 | Objects 154 |
      155 |
    1. DeliciousAccount
    2. 156 |
    157 |
  6. 158 |
  7. 159 | Attributes 160 |
      161 |
    1. Bundles
    2. 162 |
    3. Dates
    4. 163 |
    5. Headers
    6. 164 |
    7. Last Update
    8. 165 |
    9. Posts
    10. 166 |
    11. Tags
    12. 167 |
    168 |
  8. 169 |
  9. 170 | Methods 171 |
      172 |
    1. Bundles
    2. 173 |
    3. Dates
    4. 174 |
    5. Posts
    6. 175 |
    7. Tags
    8. 176 |
    9. Add (and Edit) Posts
    10. 177 |
    11. Bundle Tags
    12. 178 |
    13. Delete Posts
    14. 179 |
    15. Delete Bundles
    16. 180 |
    17. Rename Tags
    18. 181 |
    182 |
  10. 183 |
  11. 184 | GNU Free Documentation License 185 |
      186 |
    1. 0. PREAMBLE
    2. 187 |
    3. 1. APPLICABILITY AND DEFINITIONS
    4. 188 |
    5. 2. VERBATIM COPYING
    6. 189 |
    7. 3. COPYING IN QUANTITY
    8. 190 |
    9. 4. MODIFICATIONS
    10. 191 |
    11. 5. COMBINING DOCUMENTS
    12. 192 |
    13. 6. COLLECTIONS OF DOCUMENTS
    14. 193 |
    15. 7. AGGREGATION WITH INDEPENDENT WORKS
    16. 194 |
    17. 8. TRANSLATION
    18. 195 |
    19. 9. TERMINATION
    20. 196 |
    21. 10. FUTURE REVISIONS OF THIS LICENSE
    22. 197 |
    23. How to use this License for your documents
    24. 198 |
    199 |
  12. 200 |
201 |
202 |

Notes on Documentation

203 | 204 |

Attribute and method examples assume the existence of a DeliciousAccount variable d which could have been created by the following code:

205 |
import delicious
206 | d = delicious.open("username", "password")
207 |
208 |
209 |

Brief Overview

210 |
211 |

What is Python-Delicious and why is it different to all the other Python modules for del.icio.us out there?

212 |

Python-Delicious is an open source Python module to access the contents of a del.icio.us account.

213 |

While there are existing modules to interact with del.icio.us such as Delicious Python and python/delicious, they didn't provide the abstraction of del.icio.us that I wanted (that of a Python dictionary).

214 |

Also, as I was just becoming a regular user of del.icio.us and having very little to do in an Easter holiday, I decided that writing this module would be a good way to teach myself Python.

215 |

As is evident, I was heavily inspired by Mark Pilgrim's Universal Feed Parser so thanks go to him and all others who worked on it as well as Andrew Pearson who puts up with my constant e-mails.

216 |
217 |
218 |
219 |

Objects

220 |
221 |

DeliciousAccount

222 |

This is the only object in the module and is the one that does all of the work. It represents a single del.icio.us account and contains all of the attributes and methods defined in this documentation.

223 |

Two arguments MUST be specified:

224 |
225 |
username
226 |
The username for the del.icio.us account.
227 |
password
228 |
The password for the del.icio.us account.
229 |
230 |

As well as the usual Python syntax for creating a new object, two methods, open and connect, can be used like so:

231 |
import delicious
232 | 	d = delicious.DeliciousAccount("username", "password")
233 | 	d = delicious.open("username", "password")
234 | 	d = delicious.connect("username", "password")
235 |
236 |
237 |
238 |

Attributes

239 |

As the module aims to represent a del.icio.us account as a Python dictionary, data from your account is most easily accessed using the dictionary syntax of object["key"].

240 |

Important implementation note: In order to save repeatedly making requests to the del.icio.us servers, most of the following attributes are only loaded upon request. By default, a DeliciousAccount object only contains the last update information and the headers returned by the server. When some data is loaded into an attribute, simply using the usual dictionary syntax will immediately return whatever has been stored without requesting any information from del.icio.us at all: this means that if the posts method has been used to download only a selected few posts, simply calling d["posts"] (where d is your DeliciousAccount object) will only return those selected posts: not every single one of your posts as you might have expected. To work around this, simply use the posts method rather than the attribute when necessary.

241 |
242 |

Bundles

243 |
d["bundles"]
244 |

This attribute contains a list of all of the bundles in your del.icio.us account.

245 |
246 |
247 |

Dates

248 |
d["dates"]
249 |

This attribute contains a list of all of the dates on which you have made posts to del.icio.us. Each element in this list is a dictionary of the following form:

250 |
{u'count': 2,
251 | 	u'date': u'2005-05-08',
252 | 	u'date_parsed': (2005, 5, 8, 0, 0, 0, 6, 128, -1)}
253 |

The anatomy of the above dictionary is as follows:

254 |
255 |
count
256 |
The number of posts made on that date.
257 |
date
258 |
The exact string representing that date returned by del.icio.us.
259 |
date_parsed
260 |
The above date parsed into a Python time tuple of nine integers.
261 |
262 |
263 |
264 |

Headers

265 |

This attribute is a dictionary of the headers returned by the del.icio.us servers upon your last request and is of the following form:

266 |
{'transfer-encoding': 'chunked',
267 | 		'vary': '*', 
268 | 		'server': 'Apache/1.3.33 (Debian GNU/Linux) 
269 | 			mod_gzip/1.3.26.1a 
270 | 			mod_perl/1.29 
271 | 			AuthMySQL/4.3.9-2',
272 | 		'connection': 'close',
273 | 		'date': 'Sun, 08 May 2005 22:45:05 GMT',
274 | 		'content-type': 'text/xml'}
275 |
276 |
277 |

Last Update

278 |
d["lastupdate"]
279 | 	d["lastupdate_parsed"]
280 |

These two attributes contain the time that modifications were last made to your del.icio.us account. This is used internally by the module to determine when it is appropriate to redownload large amounts of content (such as all of your posts). The former attribute contains the exact string returned by the del.icio.us servers such as u'2005-05-08T18:16:03Z' whereas the latter returns a Python time tuple of nine integers such as (2005, 5, 8, 18, 16, 3, 6, 128, -1).

281 |
282 |
283 |

Posts

284 |
d["posts"]
285 |

Use sparingly! This attribute contains a list of every single post in your del.icio.us account and therefore places a relatively large load on the del.icio.us servers and should be made only when necessary. Where possible, use the more refined posts method.

286 |

Each post is a dictionary:

287 |
[{u'extended': u'For when I get back home',
288 | 		u'hash': u'5fe05afcfc229db0d6cbcb1cbdda71cf',
289 | 		u'description': u'Bonjour for Windows',
290 | 		u'tags': [u'apple', u'windows'],
291 | 		u'time_parsed': (2005, 5, 8, 18, 16, 1, 6, 128, -1),
292 | 		u'href': u'http://www.apple.com/',
293 | 		u'time': u'2005-05-08T18:16:01Z'}]
294 |

The anatomy of the above dictionary is as follows:

295 |
296 |
extended
297 |
The extended description of your post.
298 |
hash
299 |
A unique hash representing the URL used internally by del.icio.us.
300 |
description
301 |
The brief description or title of your post.
302 |
tags
303 |
A list of each tag relating to the post.
304 |
time_parsed
305 |
The time this post was made as a Python time tuple of nine integers.
306 |
href
307 |
The actual URL of the post.
308 |
time
309 |
The time this post was made as the exact string returned by the del.icio.us servers.
310 |
311 |
312 |
313 |

Tags

314 |
d["tags"]
315 |

A list of every tag in your del.icio.us account. Each element is a dictionary:

316 |
{u'count': 1, u'name': u'aggregation'}
317 |

An anatomy of the above dictionary is as follows:

318 |
319 |
count
320 |
The number of posts associated with this tag.
321 |
name
322 |
The name of this tag.
323 |
324 |
325 |
326 |
327 |

Methods

328 |

As well as being a dictionary, the DeliciousAccount object supports several methods primarily for more refined query-based retrieval of posts and dates and the manipulation of content on the server (such as adding, editing and deleting posts).

329 |
330 |

Bundles

331 |
d.bundles()
332 |

Use the attribute instead.

333 |
334 |
335 |

Dates

336 |
d.dates(tag="computing")
337 |

Has a single argument, a string tag, which will refine results so that only dates on which a post associated with the specified tag was made are returned.

338 |
339 |
340 |

Posts

341 |
d.posts(tag="computing", date="2005-05-07", count=5)
342 |

This is the most flexible method in the module and allows you to refine which posts you would like to retrieve from del.icio.us. The arguments are as follows:

343 |
344 |
tag
345 |
A string specifying with which tag posts should be associated.
346 |
date
347 |
A string, tuple, date or datetime specifying on which date the posts should have been made.
348 |
count
349 |
The number of posts to return.
350 |
351 |

If no arguments are specified, this method will return all posts from del.icio.us: this is highly discouraged as it places a large load on the del.icio.us servers. However, the module will prevent you from repeatedly downloading all posts unnecessarily as it internally will check if any changes have been made and, if not, not make a new request.

352 |
353 |
354 |

Tags

355 |
d.tags()
356 |

Use the attribute instead.

357 |
358 |
359 |

Add (and Edit) Posts

360 |
d.add(url="http://example.org/", 
361 | 		description="Example",
362 | 		extended="An example site",
363 | 		tags=('computing', 'examples'),
364 | 		date=(2005, 5, 7))
365 |

This method will add new posts to del.icio.us. Its arguments are as follows:

366 |
367 |
url
368 |
Required. The URL of the page you are bookmarking.
369 |
description
370 |
Required. A brief description for the post.
371 |
tags
372 |
A string, tuple or list of tags to associate this post with.
373 |
date
374 |
A string, tuple, list, date or datetime on which this post should be registered as made.
375 |
376 |
377 |
378 |

Bundle Tags

379 |
d.bundle(bundle="writing",
380 | 	tags=("blogging", "journalism"))
381 |

This method creates a new bundle from some existing tags. Its arguments are as follows:

382 |
383 |
bundle
384 |
Required. The name of the bundle you are creating.
385 |
tags
386 |
Required. A list or tuple of the tag names (as strings) that you wish to put inside this bundle.
387 |
388 |
389 |
390 |

Delete Posts

391 |
d.delete(url="http://example.org/")
392 |

Delete the post identified by the given URL, url.

393 |
394 |
395 |

Delete Bundles

396 |
d.delete_bundle(name="writing")
397 |

Delete the bundle identified by the given name, name.

398 |
399 |
400 |

Rename Tags

401 |
d.rename(old="blogging", new="weblogging")
402 |

Rename the tag old to new.

403 |
404 |
405 |

GNU Free Documentation License

406 |

Version 1.2, November 2002

407 |

408 | Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

409 |
410 |

0. PREAMBLE

411 |

The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

412 |

This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

413 |

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

414 |
415 |
416 |

1. APPLICABILITY AND DEFINITIONS

417 |

This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

418 |

A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

419 |

A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

420 |

The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

421 |

The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

422 |

A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque".

423 |

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

424 |

The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.

425 |

A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition.

426 |

The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

427 |
428 |
429 |

2. VERBATIM COPYING

430 |

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

431 |

You may also lend copies, under the same conditions stated above, and you may publicly display copies.

432 |
433 |
434 |

3. COPYING IN QUANTITY

435 |

If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

436 |

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

437 |

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

438 |

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

439 |
440 |
441 |

4. MODIFICATIONS

442 |

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

443 |
    444 |
  • A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
  • 445 |
  • B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
  • 446 |
  • C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
  • 447 |
  • D. Preserve all the copyright notices of the Document.
  • 448 |
  • E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
  • 449 |
  • F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
  • 450 |
  • G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
  • 451 |
  • H. Include an unaltered copy of this License.
  • 452 |
  • I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
  • 453 |
  • J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
  • 454 |
  • K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
  • 455 |
  • L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
  • 456 |
  • M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version.
  • 457 |
  • N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section.
  • 458 |
  • O. Preserve any Warranty Disclaimers.
  • 459 |
460 |

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

461 |

You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

462 |

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

463 |

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

464 |
465 |
466 |

5. COMBINING DOCUMENTS

467 |

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

468 |

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

469 |

In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements."

470 |
471 |
472 |

6. COLLECTIONS OF DOCUMENTS

473 |

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

474 |

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

475 |
476 |
477 |

7. AGGREGATION WITH INDEPENDENT WORKS

478 |

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

479 |

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

480 |
481 |
482 |

8. TRANSLATION

483 |

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

484 |

If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

485 |
486 |
487 |

9. TERMINATION

488 |

You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

489 |
490 |
491 |

10. FUTURE REVISIONS OF THIS LICENSE

492 |

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

493 |

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

494 |
495 |
496 |

How to use this License for your documents

497 |

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

498 |

Copyright (c) YEAR YOUR NAME.

499 |

Permission is granted to copy, distribute and/or modify this document 500 | under the terms of the GNU Free Documentation License, Version 1.2 501 | or any later version published by the Free Software Foundation; 502 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 503 | Texts. A copy of the license is included in the section entitled "GNU 504 | Free Documentation License".

505 |

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with...Texts." line with this:

506 |

with the Invariant Sections being LIST THEIR TITLES, with the 507 | Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

508 |

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

509 |

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

510 |
511 |
512 |
513 |
514 | 515 | 516 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup 4 | 5 | setup(name='Python-Delicious', 6 | version='pre-1.0', 7 | description='Python module to access del.icio.us via its API', 8 | author='Paul Mucur', 9 | py_modules=['delicious']) 10 | --------------------------------------------------------------------------------