Commits

Stefano Costa committed 5bde350

Make RDF templates more explicit and generic.

  • Participants
  • Parent commits 6314fee

Comments (0)

Files changed (1)

File arsw-hayes.py

 CLOSEDESC = """  </rdf:Description>
 """
 
-DESC = """  <rdf:Description rdf:about="http://archvocab.net/fineware/arsw-hayes/{1}">
-    <skos:inScheme rdf:resource="http://archvocab.net/fineware/arsw-hayes/arsw-hayes_scheme"/>
+DESC = """  <rdf:Description rdf:about="http://archvocab.net/fineware/{slug}/{resourceURI}">
+    <skos:inScheme rdf:resource="http://archvocab.net/fineware/{slug}/{slug}_scheme"/>
     <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
-    <skos:prefLabel xml:lang="en">Hayes {0}</skos:prefLabel>
+    <skos:prefLabel xml:lang="en">Hayes {resource}</skos:prefLabel>
 """
 
-BROADER = DESC + """    <skos:broadMatch rdf:resource="http://archvocab.net/fineware/arsw-hayes/{2}">
+BROADER = DESC + """    <skos:broadMatch rdf:resource="http://archvocab.net/fineware/{slug}/{broadMatchURI}">
 """
 
 FOOTER = """</rdf:RDF>"""
 
     for i in input_data:
         if ':' in i:
-            broad, narrow = i.split(':')
-            output.write(bytes(BROADER.format(narrow,
-                                              quote_plus(narrow),
-                                              quote_plus(broad)),
+            data['broadMatch'], data['resource'] = i.split(':')
+            data['resourceURI'] = quote_plus(data['resource'])
+            data['broadMatchURI'] = quote_plus(data['broadMatch'])
+            output.write(bytes(BROADER.format(**data),
                                'utf-8'))
         else:
-            output.write(bytes(DESC.format(i, quote_plus(i)), 'utf-8'))
+            data['resource'] = i
+            data['resourceURI'] = quote_plus(data['resource'])
+            output.write(bytes(DESC.format(**data), 'utf-8'))
         output.write(bytes(CLOSEDESC, 'utf-8'))
 
     output.write(bytes(FOOTER, 'utf-8'))