Stefano Costa  committed f233d71

Move scheme metadata to input file. The script is now generic.

  • Participants
  • Parent commits 5bde350

Comments (0)

Files changed (1)


     xmlns:skos="" >
   <rdf:Description rdf:about="{slug}/{slug}_scheme">
-    <rdfs:isDefinedBy>Hayes, John W. 1972. Late Roman Pottery - Hayes, John W. 1980. A supplement to Late Roman Pottery.</rdfs:isDefinedBy>
-    <skos:prefLabel xml:lang="en">Hayes African Red Slip Ware</skos:prefLabel>
+    <rdfs:isDefinedBy>{isDefinedBy}</rdfs:isDefinedBy>
+    <skos:prefLabel xml:lang="en">{prefLabel}</skos:prefLabel>
     <rdf:type rdf:resource=""/>
 def make_rdf(input_file, output_file):
     '''Use templates and input data to generate a RDF vocabulary.
-    Input files should have one resource per line. The skos:prefLabel
-    and rdfs:isDefinedBy are hardcoded in this script, but could be
-    easily moved to the top of the input file.
+    Input files should have one resource per line.
+    Scheme metadata
+    ~~~~~~~~~~~~~~~
+    rdfs:isDefinedBy and skos:prefLabel may be defined at the top of
+    the input file, in this strict order::
+        rdfs:isDefinedBy:Hayes, John W. 1972. Late Roman Pottery.
+        prefLabel:Hayes Cypriot Red Slip Ware
     output = open(output_file, 'wb')
     data = {'slug': input_file.replace('.txt','')}
+    if input_data[0].startswith('isDefinedBy:'):
+        data['isDefinedBy'] = input_data.pop(0).replace('isDefinedBy:','')
+    if input_data[0].startswith('prefLabel:'):
+        data['prefLabel'] = input_data.pop(0).replace('prefLabel:','')
     output.write(bytes(HEADER.format(**data), 'utf-8'))
     for i in input_data: