#!/usr/bin/env python # Print the changes that I need to make to my Amazon UK wishlist to make it # match the one on my web pages. # Adam Sampson import re, os, sys, xml.dom.minidom, amazonxml from amazonxml import get_text, get_wishlist_items from offog import * wishlist_id = "QH665BMD07GI" local_file = os.environ["HOME"] + "/web/offog/wishlist.hux" ll = {} f = os.popen("hux %s" % local_file, "r") data = xml.dom.minidom.parse(f) f.close() def add_all(name): for asin in data.getElementsByTagName(name): ll[get_text(asin)] = None add_all("isbn") add_all("amazon") add_all("amazonde") add_all("amazonus") print "Read %d items from local list." % len(ll) print "Reading Amazon list...", wl = get_wishlist_items(wishlist_id) print len(wl), "items" def showlist(yes, no): items = [] for asin, title in yes.items(): if not asin in no: items.append((title, asin)) items.sort() for title, asin in items: if title is None: title = "" else: title = " (%s)" % title print amazonxml.item_url(asin) + title print "In local list but not on Amazon:" showlist(ll, wl) print "On Amazon but not in local list:" showlist(wl, ll)