@@ -0,0 +1,1911 @@
+import xml.dom.minidom%0Afrom xml.dom.minidom import Node%0Aimport time%0Aimport sys, os%0A%0APROPERTIES = %7B2: (%22nie:title%22, str),%0A              3: (%22nfo:uri%22, str),%0A              4: (%22nie:usageCounter%22, int),%0A              6: (%22nie:lastRefreshed%22, time.struct_time)%7D%0A# Use time.struct_time as type for dates, even when the format is not that!%0A%0Adef get_text (node):%0A    text = %22%22%0A    for subnode in node.childNodes:%0A      if subnode.nodeType == Node.TEXT_NODE:%0A        text += subnode.data%0A    return text.encode ('utf8').replace ('%22', '') # Use a safer method!%0A%0Adef process_file (filename):%0A    doc = xml.dom.minidom.parse(filename)%0A    %0A    for node in doc.getElementsByTagName (%22node%22):%0A        print %22%3Curi:uuid:epiphany-webhistory-%25s%3E a nfo:WebHistory%22 %25 (node.getAttribute (%22id%22)),%0A        %0A        for prop in node.getElementsByTagName (%22property%22):%0A            prop_id = int(prop.getAttribute (%22id%22))%0A%0A            if (PROPERTIES.has_key (prop_id)):%0A                prop_name, prop_type = PROPERTIES %5Bprop_id%5D%0A%0A                if (prop_type == str):%0A                    print  ';%5Cn%5Ct%25s %22%25s%22' %25 (prop_name, get_text (prop)),%0A%0A                elif (prop_type == int):%0A                    print ';%5Cn%5Ct%25s %25s' %25 (prop_name, get_text (prop)),%0A%0A                elif (prop_type == time.struct_time):%0A                    print ';%5Cn%5Ct%25s %22%25s%22' %25 (prop_name, time.strftime (%22%25Y%25m%25dT%25H:%25m:%25S%22,time.localtime (int(get_text (prop))))),%0A        print %22.%5Cn%22%0A        %0A%0Adef print_headers ():%0A    print %22@prefix nfo: %3Chttp://www.semanticdesktop.org/ontologies/2007/03/22/nfo#%3E.%22%0A    print %22@prefix nie: %3Chttp://www.semanticdesktop.org/ontologies/2007/01/19/nie#%3E .%22%0A%0Aif __name__ == %22__main__%22:%0A%0A    epi_history = os.path.join (os.getenv (%22HOME%22), %22.gnome2%22, %22epiphany%22, %22ephy-history.xml%22)%0A    print %3E%3E sys.stderr, %22Scanning%22, epi_history%0A%0A    print_headers ()%0A    if (os.path.exists (epi_history)):%0A        process_file (epi_history)%0A

Add util to generate real webhistory