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

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

Fixing an indentation error

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