finish dc.yaml and update script

This commit is contained in:
Markus Döring 2015-01-13 00:53:04 +01:00 committed by Peter Desmet
parent e9360788ff
commit b907e1a718
4 changed files with 134 additions and 25 deletions

View File

@ -3,6 +3,36 @@ type:
comment: 'Examples: "StillImage", "MovingImage", "Sound", "PhysicalObject", "Event", "Text". For discussion see http://terms.tdwg.org/wiki/dwc:type'
details: http://dublincore.org/usage/terms/history/#typeT-001
modified:
definition: 'The most recent date-time on which the resource was changed. For Darwin Core, recommended best practice is to use an encoding scheme, such as ISO 8601:2004(E).'
comment: 'Examples: "1963-03-08T14:07-0600" is 8 Mar 1963 2:07pm in the time zone six hours earlier than UTC, "2009-02-20T08:40Z" is 20 Feb 2009 8:40am UTC, "1809-02-12" is 12 Feb 1809, "1906-06" is Jun 1906, "1971" is just that year, "2007-03-01T13:00:00Z/2008-05-11T15:30:00Z" is the interval between 1 Mar 2007 1pm UTC and 11 May 2008 3:30pm UTC, "2007-11-13/15" is the interval between 13 Nov 2007 and 15 Nov 2007. For discussion see http://terms.tdwg.org/wiki/dwc:modified'
details: http://dublincore.org/usage/terms/history/#modified-003
language:
definition: 'A language of the resource. Recommended best practice is to use a controlled vocabulary such as RFC 4646 [RFC4646].'
comment: 'Examples: "en" for English, "es" for Spanish. For discussion see http://terms.tdwg.org/wiki/dwc:language'
details: http://dublincore.org/usage/terms/history/#languageT-001
license:
definition: 'A legal document giving official permission to do something with the resource.'
comment: 'Examples: "http://creativecommons.org/publicdomain/zero/1.0/legalcode", "http://creativecommons.org/licenses/by/4.0/legalcode". For discussion see http://terms.tdwg.org/wiki/dwc:license'
details: http://dublincore.org/usage/terms/history/#license-002
rightsHolder:
definition: 'A person or organization owning or managing rights over the resource.'
comment: 'Example: "The Regents of the University of California.". For discussion see http://terms.tdwg.org/wiki/dwc:rightsHolder'
details: http://dublincore.org/usage/terms/history/#rightsHolder-002
accessRights:
definition: 'Information about who can access the resource or an indication of its security status. Access Rights may include information regarding access or restrictions based on privacy, security, or other policies.'
comment: 'Example: "not-for-profit use only". For discussion see http://terms.tdwg.org/wiki/dwc:accessRights'
details: http://dublincore.org/usage/terms/history/#accessRights-002
bibliographicCitation:
definition: 'A bibliographic reference for the resource as a statement indicating how this record should be cited (attributed) when used. Recommended practice is to include sufficient bibliographic detail to identify the resource as unambiguously as possible.'
comment: 'Examples: "Ctenomys sociabilis (MVZ 165861)" for a specimen, "Oliver P. Pearson. 1985. Los tuco-tucos (genera Ctenomys) de los Parques Nacionales Lanin y Nahuel Huapi, Argentina Historia Natural, 5(37):337-343." for a Taxon. For discussion see http://terms.tdwg.org/wiki/dwc:bibliographicCitation'
details: http://dublincore.org/usage/terms/history/#bibliographicCitation-002
references:
definition: 'A related resource that is referenced, cited, or otherwise pointed to by the described resource.'
comment: 'Examples: "http://mvzarctos.berkeley.edu/guid/MVZ:Mamm:165861"; "http://www.catalogueoflife.org/annual-checklist/show_species_details.php?record_id=6197868". For discussion see http://terms.tdwg.org/wiki/dwc:references'

View File

@ -6,31 +6,6 @@
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Darwin Core Term Reference</h1>
</div>
#for $group in $groups
#if $group.uri is not None
<h4><a href="#$group.name">$group.name</a></h4>
#else
<h4>$group.name</h4>
#end if
<p>
#set $sep = ''
#for $term in $group.terms
$sep <a href="#$term.name">$term.name</a>
#set $sep = '|'
#end for
</p>
#end for
<hr/>
#def showTerm($t)
#if $t.uri is not None
<a name="$t.name"></a>
@ -59,6 +34,31 @@
#end if
#end def
<body>
<div class="container">
<div class="jumbotron">
<h1>Darwin Core Term Reference</h1>
</div>
#for $group in $groups
#if $group.uri is not None
<h4><a href="#$group.name">$group.name</a></h4>
#else
<h4>$group.name</h4>
#end if
<p>
#set $sep = ''
#for $term in $group.terms
$sep <a href="#$term.name">$term.name</a>
#set $sep = '|'
#end for
</p>
#end for
<hr/>
#for $t in $groups
$showTerm(t)
#end for

3
build/requirements.txt Normal file
View File

@ -0,0 +1,3 @@
Cheetah==2.4.4
rdflib==4.1.2
PyYAML==3.11

76
build/update_terms.py Executable file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env python
'''
easy_install pip
pip install -r requirements.txt
'''
import yaml
from Cheetah.Template import Template
from rdflib import Graph, URIRef, Namespace, Literal
from rdflib.namespace import RDFS
DWC=Namespace("http://rs.tdwg.org/dwc/terms/")
DC=Namespace("http://purl.org/dc/terms/")
DWCA=Namespace("http://rs.tdwg.org/dwc/terms/attributes/")
def buildHtml():
print """building html files"""
html = Template(file="recommended.tmpl", searchList=[parseTerms()])
recommended = open("recommended.html", "w")
recommended.write(str(html))
recommended.close()
def buildDownloads():
print """building downloads"""
print """TBD"""
def getTerm(name, g):
t={}
if name.startswith("DC_"):
name=name[3:]
uri=DC[name]
t["name"]="dcterms:"+name
elif name.find(" ") > 0:
uri=None
t["name"]=name
else:
uri=DWC[name]
t["name"]=name
t["uri"]=uri
t["class"]=g.value(subject=uri, predicate=DWCA.organizedInClass)
t["definition"]=g.value(subject=uri, predicate=RDFS.comment)
t["comment"]=g.value(subject=uri, predicate=DC.description)
t["version"]=g.value(subject=uri, predicate=DC.hasVersion)
return t
def parseTerms():
with open('term_order.yaml', 'r') as f:
order = yaml.load(f)
with open('dc.yaml', 'r') as dcf:
dc = yaml.load(dcf)
g = Graph()
g.parse("../terms/dwc_normative.rdf")
for t in dc:
uri=DC[t]
g.add( (uri, RDFS.comment, Literal(dc[t]["definition"])) )
g.add( (uri, DC.description, Literal(dc[t]["comment"])) )
g.add( (uri, DC.hasVersion, URIRef(dc[t]["details"])) )
data={}
groups=[]
for groupData in order:
group=getTerm(sorted(groupData.keys())[0], g)
groups.append(group)
group["terms"]=[]
for t in sorted(groupData.values())[0]:
group["terms"].append(getTerm(t, g))
data["groups"]=groups
# print data
return data
if __name__ == "__main__":
buildHtml()
buildDownloads()