- Added support for inheritance of FOAF reading list properties
i.e. online_accounts mapping get inherited on recursion - Added extra check for foaf.weblog rdfs.seeAlso of rdf.type rss.channel - Added support for FOAF smushing when URIs are the same
This commit is contained in:
parent
72d60be8d3
commit
e029e9354e
@ -1,5 +1,7 @@
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
inheritable_options = [ 'online_accounts' ]
|
||||
|
||||
def load_accounts(config, section):
|
||||
accounts = {}
|
||||
if(config.has_option(section, 'online_accounts')):
|
||||
@ -61,6 +63,8 @@ def foaf2config(rdf, config, subject=None):
|
||||
dc = NS('http://purl.org/dc/elements/1.1/')
|
||||
foaf = NS('http://xmlns.com/foaf/0.1/')
|
||||
rdfs = NS('http://www.w3.org/2000/01/rdf-schema#')
|
||||
rdf = NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
|
||||
rss = NS('http://purl.org/rss/1.0/')
|
||||
|
||||
for statement in model.find_statements(Statement(subject,foaf.weblog,None)):
|
||||
|
||||
@ -74,9 +78,8 @@ def foaf2config(rdf, config, subject=None):
|
||||
continue
|
||||
|
||||
# blog is optional
|
||||
# TODO: check for rdf:type rss:channel
|
||||
feed = model.get_target(statement.object,rdfs.seeAlso)
|
||||
if feed:
|
||||
if feed and rss.channel == model.get_target(feed, rdf.type):
|
||||
feed = str(feed.uri)
|
||||
if not config.has_section(feed):
|
||||
config.add_section(feed)
|
||||
@ -126,9 +129,9 @@ def foaf2config(rdf, config, subject=None):
|
||||
|
||||
if not config.has_section(seeAlso):
|
||||
config.add_section(seeAlso)
|
||||
config.set(seeAlso, 'content_type', 'foaf')
|
||||
config.set(seeAlso, 'depth', str(depth - 1))
|
||||
|
||||
copy_options(config, section, seeAlso,
|
||||
{ 'content_type' : 'foaf',
|
||||
'depth' : str(depth - 1) })
|
||||
try:
|
||||
import planet
|
||||
planet.downloadReadingList(seeAlso, config,
|
||||
@ -139,6 +142,16 @@ def foaf2config(rdf, config, subject=None):
|
||||
|
||||
return
|
||||
|
||||
def copy_options(config, parent_section, child_section, overrides = {}):
|
||||
global inheritable_options
|
||||
for option in [x for x in config.options(parent_section) if x in inheritable_options]:
|
||||
if not overrides.has_key(option):
|
||||
config.set(child_section, option, config.get(parent_section, option))
|
||||
|
||||
for option, value in overrides.items():
|
||||
config.set(child_section, option, value)
|
||||
|
||||
|
||||
def friend2config(friend_model, friend, seeAlso, subconfig, data):
|
||||
|
||||
try:
|
||||
@ -162,9 +175,9 @@ def friend2config(friend_model, friend, seeAlso, subconfig, data):
|
||||
samefriend = statement.subject
|
||||
|
||||
# maybe they have the same uri
|
||||
if friend.is_resource() and samefriend.is_resource():
|
||||
# TODO
|
||||
pass
|
||||
if friend.is_resource() and samefriend.is_resource() and friend == samefriend:
|
||||
foaf2config(model, subconfig, samefriend)
|
||||
return
|
||||
|
||||
for ifp in ifps:
|
||||
object = model.get_target(samefriend,ifp)
|
||||
|
@ -5,3 +5,7 @@ cache_directory = tests/work/config/cache
|
||||
[tests/data/config/eliast.foaf]
|
||||
content_type = foaf
|
||||
depth=1
|
||||
online_accounts =
|
||||
http://del.icio.us/|http://del.icio.us/rss/{foaf:accountName}
|
||||
http://flickr.com/|http://api.flickr.com/services/feeds/photos_public.gne?id={foaf:accountName}
|
||||
|
||||
|
@ -109,7 +109,9 @@ class FoafTest(unittest.TestCase):
|
||||
config.load('tests/data/config/foaf-deep.ini')
|
||||
feeds = config.subscriptions()
|
||||
feeds.sort()
|
||||
self.assertEqual(['http://intertwingly.net/blog/atom.xml',
|
||||
self.assertEqual(['http://api.flickr.com/services/feeds/photos_public.gne?id=77366516@N00',
|
||||
'http://del.icio.us/rss/eliast', 'http://del.icio.us/rss/leef',
|
||||
'http://del.icio.us/rss/rubys', 'http://intertwingly.net/blog/atom.xml',
|
||||
'http://thefigtrees.net/lee/life/atom.xml',
|
||||
'http://torrez.us/feed/rdf'], feeds)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user