-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrependRelatedMaterialsBullets.py
48 lines (32 loc) · 1.23 KB
/
PrependRelatedMaterialsBullets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import sys
def ProcessFile(fileObj):
result = ""
line = fileObj.readline()
#skip to related materials section
while not("=Related Material" in line or "= Related Material" in line or "=Manual" in line or "==Manual" in line or "= Manual" in line or "== Manual" in line or line == ""):
result += line
line = fileObj.readline()
while not(line == ""):
if not(line[0] == "=" or line[0] == " " or line[0] == "\n" or line[0] == "-"):
line = "- " + line
result += line
line = fileObj.readline()
return result
# Set the directory you want to start from
rootDir = '.'
translatedDir = "I:\\github\\translated_files"
for dirName, subdirList, fileList in os.walk(rootDir):
#print('Found directory: %s' % dirName)
for fname in fileList:
filePath = dirName + "\\" + fname
fileCopyPath = dirName + "\\" + fname
if(".remarkup" in filePath):
print("processing: " + filePath)
fileObj = open(filePath, "r")
result = ProcessFile(fileObj)
result += " \n "
fileObj.close()
fileObj = open(fileCopyPath, "w")
fileObj.write(result)
fileObj.close()