diff -Nru swaml-0.1.0/ChangeLog swaml-0.1.1/ChangeLog --- swaml-0.1.0/ChangeLog 2008-07-25 17:31:39.000000000 +0100 +++ swaml-0.1.1/ChangeLog 2010-04-16 09:46:27.000000000 +0100 @@ -1,4 +1,8 @@ +2010-04-16 0.1.1 - Updated to sioc:UserAccount + - Fixed problem importing XML module + - Many other minor bugs fixed + 2008-07-25 0.1.0 - Patched to work with latest versions of RDFLib - Added XHTML+RDFa+GRDDL support - Adopted new URIs scheme diff -Nru swaml-0.1.0/debian/changelog swaml-0.1.1/debian/changelog --- swaml-0.1.0/debian/changelog 2010-05-10 00:24:32.000000000 +0100 +++ swaml-0.1.1/debian/changelog 2010-04-16 11:07:39.000000000 +0100 @@ -1,3 +1,14 @@ +swaml (0.1.1-1) unstable; urgency=low + + * New upstream release. + * debian/control + + Drop python-xml dependency. + + Set S-V to 3.8.4 (no changes). + * Switch to dpkg-source 3.0 (quilt) format + * Move to Debhelper compatibility level 7. + + -- Nacho Barrientos Arias Fri, 16 Apr 2010 12:15:39 +0200 + swaml (0.1.0-1) unstable; urgency=low * New upstream release. diff -Nru swaml-0.1.0/debian/compat swaml-0.1.1/debian/compat --- swaml-0.1.0/debian/compat 2010-05-10 00:24:32.000000000 +0100 +++ swaml-0.1.1/debian/compat 2010-04-16 11:07:39.000000000 +0100 @@ -1 +1 @@ -5 +7 diff -Nru swaml-0.1.0/debian/control swaml-0.1.1/debian/control --- swaml-0.1.0/debian/control 2010-05-10 00:24:32.000000000 +0100 +++ swaml-0.1.1/debian/control 2010-04-16 11:07:39.000000000 +0100 @@ -2,13 +2,13 @@ Section: web Priority: extra Maintainer: Nacho Barrientos Arias -Build-Depends: debhelper (>= 5), python-support (>= 0.4) -Standards-Version: 3.8.0 +Build-Depends: debhelper (>= 7), python-support +Standards-Version: 3.8.4 Homepage: http://swaml.berlios.de Package: swaml Architecture: all -Depends: ${python:Depends}, python-rdflib, python-xml, python-sparqlwrapper +Depends: ${python:Depends}, ${misc:Depends}, python-rdflib, python-sparqlwrapper Suggests: buxon Description: Semantic Web Archive of Mailing Lists SWAML reads a collection of email messages stored in a mailbox diff -Nru swaml-0.1.0/debian/copyright swaml-0.1.1/debian/copyright --- swaml-0.1.0/debian/copyright 2010-05-10 00:24:32.000000000 +0100 +++ swaml-0.1.1/debian/copyright 2010-04-16 11:07:54.000000000 +0100 @@ -5,7 +5,7 @@ Upstream Author: Sergio Fdez -Copyright (C) 2005-2008 +Copyright (C) 2005-2010 Sergio Fdez Diego Berrueta Jose Emilio Labra @@ -30,5 +30,5 @@ On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL' -The Debian packaging is (C) 2006-2008, Nacho Barrientos Arias +The Debian packaging is (C) 2006-2010, Nacho Barrientos Arias and is licensed under the GPL, see above. diff -Nru swaml-0.1.0/debian/rules swaml-0.1.1/debian/rules --- swaml-0.1.0/debian/rules 2010-05-10 00:24:32.000000000 +0100 +++ swaml-0.1.1/debian/rules 2010-04-16 11:07:39.000000000 +0100 @@ -16,7 +16,7 @@ install: build dh_testdir dh_testroot - dh_clean -k + dh_prep dh_installdirs $(MAKE) DESTDIR=$(CURDIR)/debian/swaml install diff -Nru swaml-0.1.0/debian/source/format swaml-0.1.1/debian/source/format --- swaml-0.1.0/debian/source/format 1970-01-01 01:00:00.000000000 +0100 +++ swaml-0.1.1/debian/source/format 2010-05-10 00:24:32.000000000 +0100 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru swaml-0.1.0/__init__.py swaml-0.1.1/__init__.py --- swaml-0.1.0/__init__.py 2008-07-25 17:31:39.000000000 +0100 +++ swaml-0.1.1/__init__.py 2010-04-16 09:46:27.000000000 +0100 @@ -1,7 +1,9 @@ +# -*- coding: utf-8 -*- + # SWAML # Semantic Web Archive of Mailing Lists # -# Copyright (C) 2005-2008 Sergio Fernández +# Copyright (C) 2005-2010 Sergio Fernández # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the @@ -13,14 +15,15 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -__author__ = 'Sergio Fdez ' +__author__ = 'Sergio Fernández ' __contributors__ = ['Diego Berrueta ', 'Jose Emilio Labra ', 'Iván Frade ', 'Nacho Barrientos '] __copyright__ = 'Copyright 2005-2008, Sergio Fernández' __license__ = 'GNU General Public License' -__version__ = '0.1.0' -__date__ = "2008-07-25" +__version__ = '0.1.1' +__date__ = "2010-04-16" __url__ = 'http://swaml.berlios.de/' __agent__ = 'http://swaml.berlios.de/doap#swaml' + diff -Nru swaml-0.1.0/manpages/swaml.1 swaml-0.1.1/manpages/swaml.1 --- swaml-0.1.0/manpages/swaml.1 2006-12-17 21:51:19.000000000 +0000 +++ swaml-0.1.1/manpages/swaml.1 2010-04-15 15:24:38.000000000 +0100 @@ -11,6 +11,7 @@ mailing list compatible with RFC 4155) and generates a RDF description. It is written in Python using SIOC as the main ontology to represent in RDF a mailing list. +.PP .SH OPTIONS .TP .B @@ -24,13 +25,13 @@ On directory /usr/share/doc/swaml/examples you should find some configuration file examples. .SH AUTHOR -Manpage written by Nacho Barrientos Arias and -Sergio Fdez for the Debian GNU/Linux system (but +Manpage written by Nacho Barrientos and +Sergio Fernandez for the Debian GNU/Linux system (but may be used by others). .SH BUGS Report bugs to Debian BTS or to http://swaml.berlios.de/bugs. .SH COPYRIGHT -Copyright \(co 2006, Sergio Fdez. Licensed under GPLv2 license. +Copyright \(co 2006, Sergio Fernandez. Licensed under GPLv2 license. .PP .nf .fam C diff -Nru swaml-0.1.0/src/swaml/rdf/foaf.py swaml-0.1.1/src/swaml/rdf/foaf.py --- swaml-0.1.0/src/swaml/rdf/foaf.py 2008-04-28 16:17:13.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/foaf.py 2008-07-29 08:09:49.000000000 +0100 @@ -275,6 +275,33 @@ return one return None + + def getHomepage(self, foaf, sha1mail): + """ + Get homepage from FOAF + + @param foaf: a foaf uri + @param sha1mail: mail addess enconded + @return: homepage url + """ + + graph = self.__getGraph(foaf) + + if (graph != None): + + sparqlGr = SPARQLGraph(graph) + select = ('?homepage') + where = GraphPattern([ ('?x', RDF['type'], FOAF['Person']), + ('?x', FOAF['mbox_sha1sum'], sha1mail), + ('?x', FOAF['homepage'], '?homepage') + ]) + + result = Query.query(sparqlGr, select, where) + + for one in result: + return one + + return None diff -Nru swaml-0.1.0/src/swaml/rdf/kml.py swaml-0.1.1/src/swaml/rdf/kml.py --- swaml-0.1.0/src/swaml/rdf/kml.py 2008-03-05 11:09:27.000000000 +0000 +++ swaml-0.1.1/src/swaml/rdf/kml.py 2010-04-15 16:28:40.000000000 +0100 @@ -20,7 +20,6 @@ import sys, os, string import xml.dom.minidom from xml.dom.minidom import getDOMImplementation -from xml.dom.ext import PrettyPrint class KML: """ @@ -112,9 +111,8 @@ #and dump it in pretty xml format - xml.dom.ext.PrettyPrint(doc, file) + file.write(doc.toprettyxml(encoding="utf-8")) - class Place: """ diff -Nru swaml-0.1.0/src/swaml/rdf/namespaces.py swaml-0.1.1/src/swaml/rdf/namespaces.py --- swaml-0.1.0/src/swaml/rdf/namespaces.py 2008-05-12 13:12:22.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/namespaces.py 2010-04-15 15:59:31.000000000 +0100 @@ -24,7 +24,7 @@ SWAML = Namespace(u"http://swaml.berlios.de/ns/0.3#") SIOC = Namespace(u"http://rdfs.org/sioc/ns#") SIOCT = Namespace(u"http://rdfs.org/sioc/types#") -DC = Namespace(u"http://purl.org/dc/elements/1.1/") +DC = Namespace(u"http://purl.org/dc/terms/") DCT = Namespace(u"http://purl.org/dc/terms/") FOAF = Namespace(u"http://xmlns.com/foaf/0.1/") GEO = Namespace(u"http://www.w3.org/2003/01/geo/wgs84_pos#") diff -Nru swaml-0.1.0/src/swaml/rdf/sindice.py swaml-0.1.1/src/swaml/rdf/sindice.py --- swaml-0.1.0/src/swaml/rdf/sindice.py 2008-06-11 09:36:44.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/sindice.py 2008-07-31 08:27:18.000000000 +0100 @@ -16,12 +16,15 @@ # for more details. """ -A python client for sindice.com +A python client for Sindice.com -seeAlso: http://sindice.com/dev/api +See also: http://sindice.com/developers/api """ +import urllib import urllib2 +import simplejson +import warnings class Sindice: @@ -30,17 +33,22 @@ Sindice constructor """ - self.service = "http://sindice.com/query/lookup?%s&format=txt" + self.service1 = "http://sindice.com/query/v1/lookup?%s&format=txt" + self.service2 = "http://api.sindice.com/v2/search?q=%s&qt=%s" - def __request(self, uri): + def __request(self, uri, accept="application/json"): """ Generic request @param uri: uri to request @return: response + @rtype: file-like object """ - headers = { 'User-Agent' : "swaml (http://swaml.berlios.de/; sergio@wikier.org)" } + headers = { + "User-Agent" : "swaml (http://swaml.berlios.de/; sergio@wikier.org)", + "Accept" : accept + } request = urllib2.Request(uri, headers=headers) return urllib2.urlopen(request) @@ -50,7 +58,10 @@ @param uri: uri to query @return: results + @rtype: list """ + + warnings.warn("This method is deprecated becuase it uses the old Sindice's API", DeprecationWarning, stacklevel=3) print "TODO" return [] @@ -61,7 +72,10 @@ @param keyword: keyword to query @return: picture results + @rtype: list """ + + warnings.warn("This method is deprecated becuase it uses the old Sindice's API", DeprecationWarning, stacklevel=3) print "TODO" return [] @@ -72,15 +86,45 @@ @param property: property to query @param object: object - @return: results + @return: results + @rtype: list """ + + warnings.warn("This method is deprecated becuase it uses the old Sindice's API", DeprecationWarning, stacklevel=3) query = "property=%s&object=%s" % (property, object) - uri = self.service % query - response = self.__request(uri) + uri = self.service1 % query + response = self.__request(uri, accept="text/plain") results = [] for line in response: line = line.split("\t") results.append((line[0], line[1])) return results + def query(self, query, qt="term"): + """ + An advanced query + + @param triple: triple/s to query + @return: results + @rtype: list + """ + + uri = self.service2 % (urllib.quote(query), qt) + response = self.__request(uri) + results = [] + json = simplejson.load(response) + for entry in json["entries"]: + link = entry["link"] + if not link in results: + results.append(link) + return results + + def sparql(self, query): + """ + A SPARQL translator + """ + + print "TODO" + return [] + diff -Nru swaml-0.1.0/src/swaml/rdf/sioc/index.py swaml-0.1.1/src/swaml/rdf/sioc/index.py --- swaml-0.1.0/src/swaml/rdf/sioc/index.py 2007-07-08 19:19:49.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/sioc/index.py 2010-04-16 09:39:21.000000000 +0100 @@ -73,6 +73,17 @@ return self.items[n-1] else: return None + + def getMessageByUri(self, uri): + """ + Get a message by URI + + @param uri: message uri + """ + for msg in self.items: + if (uri == msg.getUri()): + return msg + return None def __getTranslation(self, id): """ diff -Nru swaml-0.1.0/src/swaml/rdf/sioc/mailinglist.py swaml-0.1.1/src/swaml/rdf/sioc/mailinglist.py --- swaml-0.1.0/src/swaml/rdf/sioc/mailinglist.py 2008-07-25 17:09:40.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/sioc/mailinglist.py 2010-04-16 09:39:59.000000000 +0100 @@ -3,7 +3,7 @@ # SWAML # Semantic Web Archive of Mailing Lists # -# Copyright (C) 2005-2007 Sergio Fernández +# Copyright (C) 2005-2010 Sergio Fernández # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the @@ -21,12 +21,12 @@ import random import datetime from rdflib.Graph import ConjunctiveGraph -from rdflib import URIRef, Literal, BNode, RDF +from rdflib import URIRef, Literal, BNode from swaml.mail.mbox import Mbox from swaml.rdf.sioc.subscribers import Subscribers from swaml.rdf.sioc.message import Message from swaml.rdf.sioc.index import Index -from swaml.rdf.namespaces import RDFS, SWAML, SIOC, SIOCT, FOAF, DC, MVCB +from swaml.rdf.namespaces import RDF, RDFS, SWAML, SIOC, SIOCT, FOAF, DC, MVCB from swaml.common.date import FileDate from shutil import copyfile @@ -139,6 +139,8 @@ #self.index.delete(id) except Exception, detail: print 'Error processing message ' + str(messages) + ': ' + str(detail) + #import traceback + #traceback.print_exc(file=sys.stdout) message = mbox.nextMessage() @@ -232,11 +234,16 @@ subscribers = self.subscribers.getSubscribersUris() for uri in subscribers: store.add((list, SIOC['has_subscriber'], URIRef(uri))) + store.add((URIRef(uri), RDF.type, SIOC['UserAccount'])) - #and all messages uris - uris = self.index.getMessagesUri() - for uri in uris: + #and all messages + for msg in self.index.items: + uri = msg.getUri() store.add((list, SIOC['container_of'], URIRef(uri))) + store.add((URIRef(uri), RDF.type, SIOC['Post'])) + parent = msg.getParent() + if (parent != None): + store.add((URIRef(uri), SIOC['reply_of'], URIRef(parent))) #and dump to disk try: diff -Nru swaml-0.1.0/src/swaml/rdf/sioc/message.py swaml-0.1.1/src/swaml/rdf/sioc/message.py --- swaml-0.1.0/src/swaml/rdf/sioc/message.py 2008-07-25 17:27:11.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/sioc/message.py 2010-04-15 16:28:40.000000000 +0100 @@ -27,7 +27,6 @@ from swaml.common.date import MailDate, FileDate import xml.dom.minidom from xml.dom.minidom import getDOMImplementation, DocumentType -from xml.dom.ext import PrettyPrint class Message: """ @@ -607,11 +606,10 @@ try: xhtml_file = open(self.getXhtmlPath(), 'w+') #FIXME try: - xml.dom.ext.PrettyPrint(doc, xhtml_file) + xhtml_file.write(doc.toprettyxml(encoding="utf-8")) except UnicodeDecodeError, detail: xhtml_file.write("") print 'Decode error saving message ' + str(self.getId()) + ': ' + str(detail) - xml.dom.ext.PrettyPrint(doc, sys.stdout) xhtml_file.flush() xhtml_file.close() except IOError, detail: diff -Nru swaml-0.1.0/src/swaml/rdf/sioc/subscribers.py swaml-0.1.1/src/swaml/rdf/sioc/subscribers.py --- swaml-0.1.0/src/swaml/rdf/sioc/subscribers.py 2008-04-22 17:09:49.000000000 +0100 +++ swaml-0.1.1/src/swaml/rdf/sioc/subscribers.py 2010-04-15 15:41:53.000000000 +0100 @@ -54,6 +54,7 @@ self.doc = None self.geo = [None, None] self.pic = None + self.homepage = None self.mails = [] self.config = config @@ -123,6 +124,15 @@ """ return self.pic + + def getHomepage(self): + """ + Return his homepage + + @return: homepage url + """ + + return self.homepage def getId(self): """ @@ -218,8 +228,16 @@ """ self.pic = uri - + + def setHomepage(self, uri): + """ + Set subscriber's homepage + + @param uri: homepage url + """ + self.homepage = uri + class Subscribers: """ @@ -289,7 +307,7 @@ count += 1 user = URIRef(subscriber.getUri()) - store.add((user, RDF.type, SIOC['User'])) + store.add((user, RDF.type, SIOC['UserAccount'])) store.add((user, SIOC['subscriber_of'], URIRef(self.config.get('base') + 'forum'))) try: @@ -320,6 +338,11 @@ pic = subscriber.getPic() if (pic != None): store.add((user, SIOC['avatar'], URIRef(pic))) + + #homepage + homepage = subscriber.getHomepage() + if (pic != None): + store.add((user, FOAF['homepage'], URIRef(homepage))) except UnicodeDecodeError, detail: print 'Error proccesing subscriber ' + subscriber.getName() + ': ' + str(detail) @@ -404,12 +427,16 @@ if (lat != None and lon != None): subscriber.setGeo(lat, lon) + #picture pic = foafserv.getPic(foaf, foafserv.getShaMail(mail)) if (pic != None): subscriber.setPic(pic) - - + #homepage + homepage = foafserv.getHomepage(foaf, foafserv.getShaMail(mail)) + if (homepage != None): + subscriber.setHomepage(homepage) + def __compact(self, subscriber, foafserv): """ Compact mailing list subscribers