| | |
- DeliciousAPI
- exceptions.Exception(exceptions.BaseException)
-
- DeliciousError
-
- DeliciousItemExistsError
- PyDeliciousException
- PyDeliciousThrottled
- PyDeliciousUnauthorized
- urllib2.HTTPDefaultErrorHandler(urllib2.BaseHandler)
-
- DeliciousHTTPErrorHandler
class DeliciousAPI |
| |
A single-user Python facade to the del.icio.us HTTP API.
See http://delicious.com/help/api.
Methods ``request`` and ``request_raw`` represent the core. For all API
paths there are furthermore methods (e.g. posts_add for 'posts/all') with
an explicit declaration of parameters and documentation. |
| |
Methods defined here:
- __init__(self, user, passwd, codec='UTF-8', api_request=<function dlcs_api_request>, xml_parser=<function dlcs_parse_xml>, build_opener=<function dlcs_api_opener>, encode_params=<function dlcs_encode_params>)
- Initialize access to the API for ``user`` with ``passwd``.
``codec`` sets the encoding of the arguments, which defaults to the
users preferred locale.
The ``api_request`` and ``xml_parser`` parameters by default point to
functions within this package with standard implementations which
request and parse a resource. See ``dlcs_api_request()`` and
``dlcs_parse_xml()``.
Parameter ``build_opener`` is a callable that, provided with the
credentials, should build a urllib2 opener for the delicious API server
with HTTP authentication. See ``dlcs_api_opener()`` for the default
implementation.
``encode_params`` finally preprocesses API parameters before
they are passed to ``api_request``.
- __repr__(self)
- bundles_all(self, **kwds)
- Retrieve user bundles from del.icio.us.
::
<bundles>
<bundel name="..." tags=...">
- bundles_delete(self, bundle, **kwds)
- Delete a bundle from del.icio.us. Returns a `result` message or
raises an ``DeliciousError``. See ``request()``.
&bundle (required)
the bundle name.
- bundles_set(self, bundle, tags, **kwds)
- Assign a set of tags to a single bundle, wipes away previous
settings for bundle. Returns a `result` messages or raises an
``DeliciousError``. See ``request()``.
&bundle (required)
the bundle name.
&tags (required)
list of tags.
- get_method(self, path)
- get_url(self, url)
- Return the del.icio.us url at which the HTML page with posts for
``url`` can be found.
- posts_add(self, url, description, extended='', tags='', dt='', replace=False, shared=True, **kwds)
- Add a post to del.icio.us. Returns a `result` message or raises an
``DeliciousError``. See ``request()``.
&url (required)
the url of the item.
&description (required)
the description of the item.
&extended (optional)
notes for the item.
&tags (optional)
tags for the item (space delimited).
&dt (optional)
datestamp of the item (format "CCYY-MM-DDThh:mm:ssZ").
Requires a LITERAL "T" and "Z" like in ISO8601 at
http://www.cl.cam.ac.uk/~mgk25/iso-time.html for example:
"1984-09-01T14:21:31Z"
&replace=no (optional) - don't replace post if given url has already
been posted.
&shared=yes (optional) - wether the item is public.
- posts_all(self, tag='', start=None, results=None, fromdt=None, todt=None, meta=True, hashes=False, **kwds)
- Returns all posts. Please use sparingly. Call the `posts_update`
method to see if you need to fetch this at all.
::
<posts tag="..." user="..." update="CCYY-MM-DDThh:mm:ssZ">
<post ...>
&tag
(optional) Filter by this tag.
&start={#}
(optional) Start returning posts this many results into the set.
&results={#}
(optional) Return this many results.
&fromdt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or later
&todt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or earlier
&meta=yes
(optional) Include change detection signatures on each item in a
'meta' attribute. Clients wishing to maintain a synchronized local
store of bookmarks should retain the value of this attribute - its
value will change when any significant field of the bookmark
changes.
&hashes
(optional, exclusive) Do not fetch post details but a posts
manifest with url- and meta-hashes. Other options do not apply.
- posts_dates(self, tag='', **kwds)
- Returns a list of dates with the number of posts at each date.
::
<dates>
<date date="CCYY-MM-DD" count="888">
&tag={TAG}
(optional) Filter by this tag
- posts_delete(self, url, **kwds)
- Delete a post from del.icio.us. Returns a `result` message or
raises an ``DeliciousError``. See ``request()``.
&url (required)
the url of the item.
- posts_get(self, tag='', dt='', url='', hashes=[], meta=True, **kwds)
- Returns posts matching the arguments. If no date or url is given,
most recent date will be used.
::
<posts dt="CCYY-MM-DD" tag="..." user="...">
<post ...>
&tag={TAG} {TAG} ... {TAG}
(optional) Filter by this/these tag(s).
&dt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter by this date, defaults to the most recent date on
which bookmarks were saved.
&url={URL}
(optional) Fetch a bookmark for this URL, regardless of date.
&hashes={MD5} {MD5} ... {MD5}
(optional) Fetch multiple bookmarks by one or more URL MD5s
regardless of date.
&meta=yes
(optional) Include change detection signatures on each item in a
'meta' attribute. Clients wishing to maintain a synchronized local
store of bookmarks should retain the value of this attribute - its
value will change when any significant field of the bookmark
changes.
- posts_recent(self, tag='', count='', **kwds)
- Returns a list of the most recent posts, filtered by argument.
::
<posts tag="..." user="...">
<post ...>
&tag={TAG}
(optional) Filter by this tag.
&count={1..100}
(optional) Number of items to retrieve (Default:15, Maximum:100).
- posts_update(self, **kwds)
- Returns the last update time for the user. Use this before calling
`posts_all` to see if the data has changed since the last fetch.
::
<update time="CCYY-MM-DDThh:mm:ssZ">
- request(self, path, _raw=False, **params)
- Sends a request message to `path` in the API, and parses the results
from XML. Use with ``_raw=True`` or ``call request_raw()`` directly
to get the filehandler and process the response message manually.
Calls to some paths will return a `result` message, i.e.::
<result code="..." />
or::
<result>...</result>
These should all be parsed to ``{'result':(Boolean, MessageString)}``,
this method raises a ``DeliciousError`` on negative `result` answers.
Positive answers are silently accepted and nothing is returned.
Using ``_raw=True`` bypasses all parsing and never raises
``DeliciousError``.
See ``dlcs_parse_xml()`` and ``request_raw()``.
- request_raw(self, path, **params)
- Calls the path in the API, returns the filehandle. Returned file-
like instances have an ``HTTPMessage`` instance with HTTP header
information available. Use ``filehandle.info()`` or refer to the
``urllib2.openurl`` documentation.
- tags_delete(self, tag, **kwds)
- Delete an existing tag.
&tag={TAG}
(required) Tag to delete
- tags_get(self, **kwds)
- Returns a list of tags and the number of times it is used by the
user.
::
<tags>
<tag tag="TagName" count="888">
- tags_rename(self, old, new, **kwds)
- Rename an existing tag with a new tag name. Returns a `result`
message or raises an ``DeliciousError``. See ``request()``.
&old={TAG}
(required) Tag to rename.
&new={TAG}
(required) New tag name.
Data and other attributes defined here:
- paths = {'posts/add': 'posts_add', 'posts/all': 'posts_all', 'posts/dates': 'posts_dates', 'posts/delete': 'posts_delete', 'posts/get': 'posts_get', 'posts/recent': 'posts_recent', 'posts/update': 'posts_update', 'tags/bundles/all': 'bundles_all', 'tags/bundles/delete': 'bundles_delete', 'tags/bundles/set': 'bundles_set', ...}
|
class DeliciousHTTPErrorHandler(urllib2.HTTPDefaultErrorHandler) |
| | |
- Method resolution order:
- DeliciousHTTPErrorHandler
- urllib2.HTTPDefaultErrorHandler
- urllib2.BaseHandler
Methods defined here:
- http_error_401(self, req, fp, code, msg, headers)
- http_error_503(self, req, fp, code, msg, headers)
Methods inherited from urllib2.HTTPDefaultErrorHandler:
- http_error_default(self, req, fp, code, msg, hdrs)
Methods inherited from urllib2.BaseHandler:
- __lt__(self, other)
- add_parent(self, parent)
- close(self)
Data and other attributes inherited from urllib2.BaseHandler:
- handler_order = 500
|
|