Changeset 26329
- Timestamp:
- 2012-10-17T15:01:06+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-cols/niupepa/issuetoitem.py
r26323 r26329 5 5 6 6 def findIssueFiles(startDir): 7 8 9 7 for currentDir, dirs, filenames in os.walk(startDir): 8 for filename in filenames: 9 if re.search(r'^.*\.issue$', filename, re.M): 10 10 11 12 13 14 11 filenamePrefix = filename.split(".")[0] 12 filenameSegments = filenamePrefix.split("_") 13 volume = filenameSegments[1] 14 issue = filenameSegments[2] 15 15 16 17 18 19 16 #Read the issue file 17 i = open(os.path.join(currentDir, filename)) 18 lines = i.readlines() 19 i.close() 20 20 21 22 21 #Create a new item file 22 o = open(os.path.join(currentDir, filename.replace("issue", "item")), "w") 23 23 24 25 26 27 24 if len(volume) > 0: 25 o.write("<Volume>" + volume + "\n") 26 if len(issue) > 0: 27 o.write("<Issue>" + issue + "\n") 28 28 29 count = 0 30 for line in lines: 31 if line.startswith("<"): 32 o.write(line) 33 else: 34 count += 1 35 line = line.rstrip() 36 nameSegments = line.split("_") 37 o.write(nameSegments[len(nameSegments)-1] + ":images/" + line + ".gif:text/" + line + ".txt\n") 38 o.close() 29 count = 0 30 for line in lines: 31 if line.startswith("<"): 32 o.write(line) 33 else: 34 count += 1 35 line = line.rstrip() 36 nameSegments = line.split("_") 37 o.write(nameSegments[len(nameSegments)-1] + ":images/" + line + ".gif:text/" + line + ".txt\n") 38 o.close() 39 39 40 40 41 findIssueFiles('.')
Note:
See TracChangeset
for help on using the changeset viewer.