git @ Cat's Eye Technologies The-Dipple / f6a1126
Remove executable from scripts you're not likely to want to run. Chris Pressey 7 years ago
11 changed file(s) with 65 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
(No changes)
0 #!/usr/bin/env python
1
2 # a little experiment; try it with redirected input, and without
3
4 import sys
5
6 print sys.stdin.tell()
7 line = sys.stdin.readline()
8 print line
9 print sys.stdin.tell()
10 sys.stdin.seek(0, 0)
11 line = sys.stdin.readline()
12 print line
13 print sys.stdin.tell()
+0
-14
python/stream.py less more
0 #!/usr/bin/env python
1
2 # a little experiment; try it with redirected input, and without
3
4 import sys
5
6 print sys.stdin.tell()
7 line = sys.stdin.readline()
8 print line
9 print sys.stdin.tell()
10 sys.stdin.seek(0, 0)
11 line = sys.stdin.readline()
12 print line
13 print sys.stdin.tell()
0 #!/usr/bin/env python
1
2 # Convert a text file into a Commodore BASIC 2.0 program which displays
3 # the text file.
4
5 # The output program can be tokenized with petcat, e.g.
6 # txt2bas.py <doc.txt >doc.bas
7 # petcat -w2 -o doc.prg -- doc.bas
8
9 import re
10 import sys
11 import fileinput
12 from optparse import OptionParser
13
14
15 if __name__ == '__main__':
16 parser = OptionParser()
17
18 (options, args) = parser.parse_args()
19 prompt = '[press RETURN]';
20 clear = (' ' * (len(prompt) + 1)) + ('{left}' * (len(prompt) + 1))
21
22 print '5 print"{clr}";chr$(14);'
23 line_number = 10
24 for line in fileinput.input(args):
25 line = line.rstrip()
26 ender = ''
27 if len(line) > 40:
28 raise ValueError("line too long: %s" % line)
29 if len(line) == 40:
30 ender = ';'
31 line = re.sub(r'"', '";chr$(34);"', line)
32 print '%d print"%s"%s' % (
33 line_number, line, ender)
34 if line_number % 230 == 0:
35 print '%d input"%s";a$' % (line_number + 5, prompt)
36 print '%d print"{up}%s";' % (line_number + 6, clear)
37 line_number += 10
38
39 sys.exit(0)
+0
-40
python/txt2bas.py less more
0 #!/usr/bin/env python
1
2 # Convert a text file into a Commodore BASIC 2.0 program which displays
3 # the text file.
4
5 # The output program can be tokenized with petcat, e.g.
6 # txt2bas.py <doc.txt >doc.bas
7 # petcat -w2 -o doc.prg -- doc.bas
8
9 import re
10 import sys
11 import fileinput
12 from optparse import OptionParser
13
14
15 if __name__ == '__main__':
16 parser = OptionParser()
17
18 (options, args) = parser.parse_args()
19 prompt = '[press RETURN]';
20 clear = (' ' * (len(prompt) + 1)) + ('{left}' * (len(prompt) + 1))
21
22 print '5 print"{clr}";chr$(14);'
23 line_number = 10
24 for line in fileinput.input(args):
25 line = line.rstrip()
26 ender = ''
27 if len(line) > 40:
28 raise ValueError("line too long: %s" % line)
29 if len(line) == 40:
30 ender = ';'
31 line = re.sub(r'"', '";chr$(34);"', line)
32 print '%d print"%s"%s' % (
33 line_number, line, ender)
34 if line_number % 230 == 0:
35 print '%d input"%s";a$' % (line_number + 5, prompt)
36 print '%d print"{up}%s";' % (line_number + 6, clear)
37 line_number += 10
38
39 sys.exit(0)
+0
-11
python/unformat less more
0 #!/usr/bin/env python
1
2 import sys
3 import re
4
5 for line in sys.stdin:
6 for w in re.finditer(r'(\<.*?\>|[^<\s]+)', line):
7 w = w.group(1)
8 w = re.sub(r'(\#|\`|\-|\(|\)|\|\=|\*)', '', w)
9 if w and not w.startswith('<'):
10 print w
0 #!/usr/bin/env python
1
2 import sys
3 import re
4
5 for line in sys.stdin:
6 for w in re.finditer(r'(\<.*?\>|[^<\s]+)', line):
7 w = w.group(1)
8 w = re.sub(r'(\#|\`|\-|\(|\)|\|\=|\*)', '', w)
9 if w and not w.startswith('<'):
10 print w
(No changes)