Changeset 887
- Timestamp:
- 11/12/10 13:35:53 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
metadata/trunk/toolkit/scripts/dir2cmdicollection.py
r886 r887 85 85 name = "OLAC: " + collectionName.replace("_", " ") 86 86 idx = "" 87 path = "" 87 88 for item in collectionList: 88 89 # trying to restore the original id (which is in the MdSelfLink 89 if os.path.isfile(item) and ref_flag=="handle":90 if os.path.isfile(item): 90 91 for line in open(item): 91 92 if "<MdSelfLink>" in line: … … 94 95 break 95 96 else: 96 idx = item 97 idx = item 98 99 if ref_flag=="path": 100 # need to add '../' for the number of dirs in the target_dir, so paths match again. 101 path = "../"+item 102 else: 103 path = idx; 104 97 105 #idx = item.replace(".xml.cmdi","").replace("_", ":",1)[::-1].replace("_", ":",1)[::-1].replace("_", "-") 98 resourceProxies += "\n" + resourceTemplate.substitute(idname = idx.replace(".","_").replace("/","_").replace("\\","_"), idx = idx)106 resourceProxies += "\n" + resourceTemplate.substitute(idname = idx.replace(".","_").replace("/","_").replace("\\","_"), idx = path) 99 107 if collectionName=="olac-root": 100 108 collidx = "olac-root" 101 109 else: 102 110 # print "idx:" + idx 103 if idx!="" and ref_flag=="handle":111 if idx!="": 104 112 collidx = idx[:idx.rfind(":")] # this is just a hack to derive the collection-id from the id of the collection-item (stripping the running number) 105 113 else: … … 107 115 print collidx 108 116 outfile = outstring.substitute(date= datetime.datetime.now().strftime("%Y-%m-%d"), selflink=collidx, rp=resourceProxies,url=url, name=name) 109 f = open(target_dir + collectionFile, 'w') 117 collectionFile = target_dir + collectionFile 118 f = open(collectionFile, 'w') 110 119 f.write(outfile) 111 120 f.close() 112 121 113 122 print collectionFile 114 return collidx 123 if ref_flag=="path": 124 return collectionFile 125 else: 126 return collidx 115 127 116 128 main()
Note: See TracChangeset
for help on using the changeset viewer.