comparison diff-colorize.py @ 6:d58b4e2e12d4

Moved the imports of sys and fileinput, so that all the imports are together.
author Peter Hosey
date Mon, 11 Aug 2008 00:14:01 -0700
parents fa7cd4c2716b
children c6337f653d9b
comparison
equal deleted inserted replaced
5:fa7cd4c2716b 6:d58b4e2e12d4
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import sys
3 import os 4 import os
5 import fileinput
4 6
5 INDEX_COLOR = int(os.environ.get('DIFF_INDEX_COLOR', 32)) 7 INDEX_COLOR = int(os.environ.get('DIFF_INDEX_COLOR', 32))
6 OLD_MODE_COLOR = int(os.environ.get('DIFF_OLD_MODE_COLOR', 124)) 8 OLD_MODE_COLOR = int(os.environ.get('DIFF_OLD_MODE_COLOR', 124))
7 NEW_MODE_COLOR = int(os.environ.get('DIFF_NEW_MODE_COLOR', 28)) 9 NEW_MODE_COLOR = int(os.environ.get('DIFF_NEW_MODE_COLOR', 28))
8 REMOVED_COLOR = int(os.environ.get('DIFF_REMOVED_COLOR', 203)) 10 REMOVED_COLOR = int(os.environ.get('DIFF_REMOVED_COLOR', 203))
78 COLOR_FORMAT % (HUNK_START_COLOR,) 80 COLOR_FORMAT % (HUNK_START_COLOR,)
79 + BEGIN_REVERSE_FORMAT 81 + BEGIN_REVERSE_FORMAT
80 + '@@' 82 + '@@'
81 ) 83 )
82 84
83 import sys
84 import fileinput
85
86 for line in fileinput.input(): 85 for line in fileinput.input():
87 for prefix_to_test in prefixes: 86 for prefix_to_test in prefixes:
88 if line.startswith(prefix_to_test): 87 if line.startswith(prefix_to_test):
89 sys.stdout.write(prefixes[prefix_to_test]) 88 sys.stdout.write(prefixes[prefix_to_test])
90 line = line[len(prefix_to_test):] 89 line = line[len(prefix_to_test):]