CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 07 Aug 2025 19:50:56 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20160126123424
location: https://web.archive.org/web/20160126123424/https://xmlns.com/foaf/0.1/specgen.py
server-timing: captures_list;dur=0.657216, exclusion.robots;dur=0.022624, exclusion.robots.policy;dur=0.009412, esindex;dur=0.015765, cdx.remote;dur=22.925507, LoadShardBlock;dur=581.173174, PetaboxLoader3.datanode;dur=309.581155, PetaboxLoader3.resolve;dur=96.137280
x-app-server: wwwb-app214
x-ts: 302
x-tr: 628
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app214; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 07 Aug 2025 19:50:57 GMT
content-type: text/x-python
content-length: 8516
x-archive-orig-date: Tue, 26 Jan 2016 12:32:50 GMT
x-archive-orig-server: Apache/2.4.7 (Ubuntu)
x-archive-orig-access-control-allow-origin: *
x-archive-orig-last-modified: Sun, 23 Jan 2011 19:42:36 GMT
x-archive-orig-etag: "2144-49a88af74aad6"
x-archive-orig-accept-ranges: bytes
x-archive-orig-content-length: 8516
x-archive-orig-connection: close
cache-control: max-age=1800
x-archive-guessed-content-type: text/x-python
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 26 Jan 2016 12:34:24 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 04 Apr 2005 10:17:15 GMT", ; rel="prev memento"; datetime="Tue, 17 Nov 2015 02:07:29 GMT", ; rel="memento"; datetime="Tue, 26 Jan 2016 12:34:24 GMT", ; rel="next memento"; datetime="Sat, 12 Mar 2016 21:12:24 GMT", ; rel="last memento"; datetime="Wed, 30 Jul 2025 01:23:48 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: alexa20160127-13/52_50_20160126123357_crawl301.arc.gz
server-timing: captures_list;dur=0.990236, exclusion.robots;dur=0.043742, exclusion.robots.policy;dur=0.023408, esindex;dur=0.019312, cdx.remote;dur=34.069369, LoadShardBlock;dur=128.208524, PetaboxLoader3.datanode;dur=89.521548, PetaboxLoader3.resolve;dur=179.436488, load_resource;dur=164.366631
x-app-server: wwwb-app214
x-ts: 200
x-tr: 362
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
import sys
import re
import urllib
import RDF
foaf = RDF.NS("https://xmlns.com/foaf/0.1/")
dc = RDF.NS('https://purl.org/dc/elements/1.1/')
rdf = RDF.NS('https://www.w3.org/1999/02/22-rdf-syntax-ns#')
rdfs = RDF.NS('https://www.w3.org/2000/01/rdf-schema#')
owl = RDF.NS('https://www.w3.org/2002/07/owl#')
vs = RDF.NS('https://www.w3.org/2003/06/sw-vocab-status/ns#')
classranges = {}
classdomains = {}
def termlink(string):
"""FOAF specific: function which replaces Domain: \n\t%s \n" % domain
if range:
if ("https://xmlns.com/foaf/0.1/" in range):
range = range.replace("https://xmlns.com/foaf/0.1/", "")
range = """foaf:%s""" % (range, range)
doc += "\tRange: \n\t%s \n" % range
return doc
def rdfsClassInfo(term,m):
"""Generate rdfs-type information for Classes: ranges, and domains."""
global classranges
global classdomains
doc = ""
# Find out about properties which have rdfs:range of t
r = classranges.get(str(term.uri), "")
if r:
rlist = ''
for k in r:
kname = k
if ("https://xmlns.com/foaf/0.1/" in k):
k = k.replace("https://xmlns.com/foaf/0.1/", "")
k = """foaf:%s""" % (k, k)
rlist += "%s " % k
doc += "in-range-of: "+rlist+" "
# Find out about properties which have rdfs:domain of t
d = classdomains.get(str(term.uri), "")
if d:
dlist = ''
for k in d:
kname = k
if ("https://xmlns.com/foaf/0.1/" in k):
k = k.replace("https://xmlns.com/foaf/0.1/", "")
k = """foaf:%s""" % (k, k)
dlist += "%s " % k
doc += "in-domain-of: "+dlist+" "
return doc
def owlInfo(term,m):
"""Returns an extra table row if the term (an RDF.Node()) is an IFP."""
o = m.find_statements(RDF.Statement(term, rdf.type, owl.InverseFunctionalProperty))
if o.current():
return("\tOWL Type: \n\tAn InverseFunctionalProperty (uniquely identifying property) \n")
return ''
def docTerms(category, list, m):
"""A wrapper class for listing all the terms in a specific class (either
Properties, or Classes. Category is 'Property' or 'Class', list is a
list of term names (strings), return value is a chunk of HTML."""
doc = ""
nspre = "foaf"
for t in list:
term = foaf[t]
doc += """
foaf:*
with a
link to the term in the document."""
return re.sub(r"foaf:(\w+)
", r"""foaf:\1
""", string)
def return_name(m, urinode):
"Trims the FOAF namespace out of a term to give a name to the term."
return str(urinode.uri).replace("https://xmlns.com/foaf/0.1/", "")
def get_rdfs(m, urinode):
"Returns label and comment given an RDF.Node with a URI in it"
l = m.find_statements(RDF.Statement(urinode, rdfs.label, None))
label = l.current().object.literal_value['string']
c = m.find_statements(RDF.Statement(urinode, rdfs.comment, None))
comment = c.current().object.literal_value['string']
return label, comment
def get_status(m, urinode):
"Returns the status text for a term."
s = m.find_statements(RDF.Statement(urinode, vs.term_status, None))
return s.current().object.literal_value['string']
def htmlDocInfo( t, termdir="../doc" ):
"""Opens a file based on the term name (t) and termdir (defaults to
current directory. Reads in the file, and returns a linkified
version of it."""
doc = ""
try:
f = open("%s/%s.en" % (termdir, t), "r")
doc = f.read()
doc = termlink(doc)
except:
return "No detailed documentation for this term.
" return doc def rdfsPropertyInfo(term,m): """Generate HTML for properties: Domain, range, status.""" doc = "" range = "" domain = "" # domain and range stuff (properties only) d = m.find_statements(RDF.Statement(term, rdfs.domain, None)) if d.current(): domain = d.current().object.uri domain = str(domain) else: domain = "" r = m.find_statements(RDF.Statement(term, rdfs.range, None)) if r.current(): range = r.current().object.uri range = str(range) if domain: if ("https://xmlns.com/foaf/0.1/" in domain): domain = domain.replace("https://xmlns.com/foaf/0.1/", "") domain = """foaf:%s""" % (domain, domain) doc += "\t\n
" % (label, comment) doc += """\n\t
\n"
doc += htmlDocInfo(t)
#danbri
doc += "
\n
\n\n"
return doc
def buildazlist(classlist, proplist):
"""Builds the A-Z list of terms. Args are a list of classes (strings) and
a list of props (strings)"""
azlist = """%s: %s:%s
\n""" % (t, category, nspre, t) label, comment = get_rdfs(m, term) status = get_status(m, term) doc += "%s - %s" % (label, comment) doc += """
Status: | \n\t%s |
---|
[#]
\n\n" % (return_name(m,term)) doc += "\n\n" doc += "\n\n
"""
azlist = """%s\n
""" % azlist
return azlist
def specInformation(m):
"""Read through the spec (provided as a Redland model) and return classlist
and proplist. Global variables classranges and classdomains are also filled
as appropriate."""
global classranges
global classdomains
# Find the class information: Ranges, domains, and list of all names.
classlist = []
for classStatement in m.find_statements(RDF.Statement(None, rdf.type, rdfs.Class)):
for range in m.find_statements(RDF.Statement(None, rdfs.range, classStatement.subject)):
classranges.setdefault(str(classStatement.subject.uri), []).append(str(range.subject.uri))
for domain in m.find_statements(RDF.Statement(None, rdfs.domain, classStatement.subject)):
classdomains.setdefault(str(classStatement.subject.uri), []).append(str(domain.subject.uri))
classlist.append(return_name(m, classStatement.subject))
# Create a list of properties in the schema.
proplist = []
for propertyStatement in m.find_statements(RDF.Statement(None, rdf.type, rdf.Property)):
proplist.append(return_name(m, propertyStatement.subject))
return classlist, proplist
def main(specloc = "file:index.rdf"):
"""The meat and potatoes: Everything starts here."""
m = RDF.Model()
p = RDF.Parser()
p.parse_into_model(m, specloc)
classlist, proplist = specInformation(m)
# Build HTML list of terms.
azlist = buildazlist(classlist, proplist)
# Generate Term HTML
termlist = "Classes: |""" % azlist classlist.sort() for c in classlist: azlist = """%s %s | """ % (azlist, c.replace(" ", ""), c) azlist = """%s\n
""" % azlist azlist = """%s\nProperties: |""" % azlist proplist.sort() for p in proplist: azlist = """%s %s | """ % (azlist, p.replace(" ", ""), p) azlist = """%s\n
""" % azlist azlist = """%s\nClasses and Properties (full detail)
" termlist += ""
termlist += docTerms('Class',classlist,m)
termlist += docTerms('Property',proplist,m)
termlist += "
"
# Generate RDF from original namespace.
u = urllib.urlopen(specloc)
rdfdata = u.read()
rdfdata.replace("""""", "")
# wip.template is a template file for the spec, python-style % escapes
# for replaced sections.
f = open("../0.1/template.html", "r")
template = f.read()
print template % (azlist.encode("utf-8"), termlist.encode("utf-8"), rdfdata)
if __name__ == "__main__":
"""Specification generator tool, created for FOAF schema maintenance."""
if (len(sys.argv) >= 2):
main(sys.argv[1])
else:
main()