Changeset 905
- Timestamp:
- 11/15/10 14:49:32 (14 years ago)
- Location:
- metadata/trunk/toolkit/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
metadata/trunk/toolkit/scripts/dir2cmdicollection.py
r887 r905 13 13 # 'path' := the relative path of the record 14 14 15 import os, datetime 15 import os, datetime, sys 16 16 from string import Template 17 17 … … 19 19 ref_flag = "path" # "handle" | "path" 20 20 21 21 22 def main(): 23 simple_dir_structure = False 24 if len(sys.argv) > 1: 25 if sys.argv[1] == "-simpledir": 26 simple_dir_structure = True 27 22 28 rootList = [] 23 29 if not os.path.isdir(target_dir): 24 30 os.mkdir(target_dir) 25 for root, dirs, files in os.walk(os.getcwd()): 26 startpath = os.getcwd() 27 for d in dirs: 28 if d == "0": 29 rootList.append(generate_branch(root, dirs)) 31 32 if not simple_dir_structure: 33 for root, dirs, files in os.walk(os.getcwd()): 34 startpath = os.getcwd() 35 for d in dirs: 36 if d == "0": 37 rootList.append(generate_branch(root, dirs)) 38 else: 39 rootList.append(generate_branch(os.getcwd(), [""], "lrt_inventory")) 30 40 writeCollection(rootList, "collection_root.cmdi", "olac-root") 31 41 32 42 def generate_branch(root, dirs): 33 43 collectionName = os.path.relpath(root) 44 return generate_branch(root, dirs, collectionName) 45 46 def generate_branch(root, dirs, collectionName): 47 #collectionName = os.path.relpath(root) 34 48 collectionFile = "collection_%s.cmdi" % collectionName 35 49 -
metadata/trunk/toolkit/scripts/lrt2cmdi.py
r884 r905 17 17 18 18 def fillElement(self, xpath, value): 19 #print "fill %s with %s" % (xpath, value) 19 20 self.xmlTree.find(xpath).text = value.strip() 20 21 21 22 def fillMultipleElement(self, elementname, xpath, values): 22 23 # fill in the already existing element 23 if values[0]: 24 #print values 25 if (values[0]): 26 #print "first one", values[0] 27 #print values[0] 24 28 self.fillElement(xpath, values[0]) 29 #print "fill %s with %s" % (xpath, values[0]) 30 #print 25 31 26 32 element = self.xmlTree.find(xpath) … … 31 37 for value in values[1:]: 32 38 if value: 33 # create new sibling of xpath (elementname) = value 39 # create new sibling of xpath (elementname) = value 40 #print value 41 #print "next one", value 34 42 position += 1 35 43 newElement = ElementTree.Element(elementname) … … 56 64 uniqueItems = set(items) # filter out double items 57 65 items = [i for i in uniqueItems] # convert set back to a list 66 #print items 67 58 68 self.fillMultipleElement("Institute", "//LrtCommon/Institute", items) 59 69 … … 193 203 194 204 def loadInfo(): 195 #csvFile = csv.reader(urllib.urlopen("http://www.clarin.eu/export_resources").readlines())196 csvFile = csv.reader(urllib.urlopen("resources.csv").readlines())205 csvFile = csv.reader(urllib.urlopen("http://www.clarin.eu/export_resources").readlines()) 206 #csvFile = csv.reader(urllib.urlopen("resources.csv").readlines()) 197 207 linenr = 0 198 208 newDict = dict()
Note: See TracChangeset
for help on using the changeset viewer.