Newer
Older
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
#!/bin/env python
# $Id: adiforfix.py,v 1.3 2001/08/24 16:32:18 bsmith Exp $
#
# change python to whatever is needed on your system to invoke python
#
# Adds & continuation marker to the end of continued lines
#
# Calling sequence:
# | adiforfix.py
#
import urllib
import os
import ftplib
import httplib
import sys
from exceptions import *
from sys import *
from string import *
def main():
lines = sys.stdin.readlines()
n = len(lines)
for i in range(0,n):
lines[i]=replace(lines[i],"\t"," ")
for i in range(0,n):
# replace tab with 6 spaces
if len(lines[i]) > 0:
if (lines[i][0] == '\t'):
lines[i] = " "+lines[i][1:]
# replace comment indicator with !
if len(lines[i]) > 0:
if (lines[i][0] == 'c') | (lines[i][0] == 'C') | (lines[i][0] == '*'):
lines[i] = "!"+lines[i][1:]
# move number right one position
# if len(lines[i]) > 0:
# if (lines[i][0] != ' ') & (lines[i][0] != '!') & (lines[i][0] != '#'):
# lines[i] = " "+lines[i]
# replace continuation indicator with &
if len(lines[i]) > 6:
if (lines[i][5] != ' ') & (lines[i][5] != '\t') & (lines[i][0] == ' '):
lines[i] = " &"+lines[i][6:]
for i in range(0,n):
if lines[i][0] == ' ':
# is next line a continued line
for j in range(i+1,n):
if len(lines[j]) > 6:
if (lines[j][5] == '&') & (lines[j][0] == ' '):
lines[i] = rstrip(lines[i])+" "
lines[i] = lines[i][0:72]+"&\n"
break
elif (lines[j][0] == ' '):
break
# replace E - with E-
lines[i]=replace(lines[i],"E - ","E-")
sys.stdout.writelines(lines)
#
# The classes in this file can also be used in other python-programs by using 'import'
#
if __name__ == '__main__':
main()