Source

yummy / src / yummy / api.py

Full commit
import os
from pit import  Pit
import urllib2
from xml.dom import minidom

UA='Python yummy.py'

class Api(object):

    def __init__(self,conf=None):
        if conf == None:
            conf =Pit.get('delicious')

        self.conf = conf
        self.conf['UA'] = UA
        self.basic_auth()

    def basic_auth(self):
        conf = self.conf
        auth_handler = urllib2.HTTPBasicAuthHandler()
        auth_handler.add_password("del.icio.us API", "%(api_scheme)s://%(api_host)s/" % conf, 
                                conf['username'], conf['password'])
    
        opener = urllib2.build_opener(auth_handler)
        opener.addheaders = [("User-agent", conf['UA'])] 
        urllib2.install_opener(opener)

    
    def _request(self,url):
        res = urllib2.urlopen(url)
        return  minidom.parseString(res.read())

    def post(self,tag=None):
        url =  "%(api_scheme)s://%(api_host)s/%(api_ver)s/posts/all?" % self.conf
        if tag:
            #: URL encoding....
            url = url + "tag=%s" % tag

        return self._reuqest(url)