-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproString.py
More file actions
55 lines (50 loc) · 1.15 KB
/
Copy pathproString.py
File metadata and controls
55 lines (50 loc) · 1.15 KB
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
49
50
51
52
53
54
55
#!/usr/bin/python
import os, sys
# open a fifo queue for reading, read 10 strings, close fifo
# reads text from another queue sent by the reader program
filename = "q1"
pipe = open(filename, "r")
line1 = pipe.readline() [:-1]
line = pipe.readline()
os.remove(filename)
f1 = file("q2", "w+")
str1 = "<HTML>\n\n\n"
str3 = "<head>\n<title>"
str4 = "</title>\n</head>\n\n<body>\n"
str5 = str3+line1+str4
str2 = "\n</body>\n\n</HTML>"
line = str1+str5+line+str2
# read info file
line1 = line1 + ".info"
f = open (line1)
while True:
line2 = f.readline()
if line2:
line2 = line2.strip('\n')
if line2[0] == 'I':
str6 = line2[2:len(line)]
str7 = "<I>"
str8 = "</I>"
str9 = str7+str6+str8
line = line.replace(str6, str9)
#f1.writelines(line);
elif line2[0] == 'B':
str6 = line2[2:len(line)]
str7 = "<B>"
str8 = "</B>"
str9 = str7+str6+str8
line = line.replace(str6, str9)
#f1.writelines(line);
elif line2[0] == 'U':
str6 = line2[2:len(line)]
str7 = "<U>"
str8 = "</U>"
str9 = str7+str6+str8
line = line.replace(str6, str9)
#f1.writelines(line);
else:
break;
f1.writelines(line);
f.close()
f1.close();
#print line