source: main/trunk/model-cols/niupepa/issuetoitem.py@ 26889

Last change on this file since 26889 was 26329, checked in by sjm84, 12 years ago

Fixing an indentation error

  • Property svn:executable set to *
File size: 1.2 KB
RevLine 
[26201]1#!/usr/bin/python
2
3import os
4import re
5
6def findIssueFiles(startDir):
[26329]7 for currentDir, dirs, filenames in os.walk(startDir):
8 for filename in filenames:
9 if re.search(r'^.*\.issue$', filename, re.M):
[26201]10
[26329]11 filenamePrefix = filename.split(".")[0]
12 filenameSegments = filenamePrefix.split("_")
13 volume = filenameSegments[1]
14 issue = filenameSegments[2]
[26201]15
[26329]16 #Read the issue file
17 i = open(os.path.join(currentDir, filename))
18 lines = i.readlines()
19 i.close()
[26201]20
[26329]21 #Create a new item file
22 o = open(os.path.join(currentDir, filename.replace("issue", "item")), "w")
[26201]23
[26329]24 if len(volume) > 0:
25 o.write("<Volume>" + volume + "\n")
26 if len(issue) > 0:
27 o.write("<Issue>" + issue + "\n")
[26201]28
[26329]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()
[26201]39
[26329]40
[26201]41findIssueFiles('.')
Note: See TracBrowser for help on using the repository browser.