forked from klevasseur/ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversion.py
executable file
·40 lines (34 loc) · 931 Bytes
/
conversion.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
#!/usr/bin/env python -tt
import sys
import re
import string
# First remove all \n's and the comments before and after Notebook[ ] manually
def XMLCell(str):
parts=re.findall('["B](.+?)"',str)
t= '<'+parts[0]+'>'+parts[1]+'</'+parts[0]+'>'
print [str, parts]
return t
# Calls the above functions with interesting inputs.
def main():
path=sys.argv[1]
# import file as large text string
f = open(path, 'rU')
text = f.read()
steps=len(re.findall('Cell\[',text))
print steps
count=0
while count<8:
print count
print '<-----\n'
first= re.findall(r'Cell\[.+?]',text)
print first
text=string.replace(text,first[0],XMLCell(first[0]))
count+=1
# print re.sub(first[0],XMLCell,text)
print '-------------------------'
# print re.sub(first[0],XMLCell(first[0]),text)
# print string.replace(text,first[0],XMLCell(first[0]))
print text
print '-------------------------'
if __name__ == '__main__':
main()