diff options
author | Tim Hatch <tim@timhatch.com> | 2014-04-14 14:58:34 -0400 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-04-14 14:58:34 -0400 |
commit | 1add9dd59c4725a851e01f34107081b814903c98 (patch) | |
tree | 1b44ada8e9a20d677f0641de969536c0e30e4796 /scripts/vim2pygments.py | |
parent | e49fcb63aac76df1ca5863327928054e32802432 (diff) | |
parent | 3394e774607f349bdc153126a368b3fb8d07bd84 (diff) | |
download | pygments-1add9dd59c4725a851e01f34107081b814903c98.tar.gz |
Merged in ziggix/pygments-main (pull request #211)
Conflicts:
pygments/lexers/_mapping.py
pygments/lexers/other.py
Diffstat (limited to 'scripts/vim2pygments.py')
-rwxr-xr-x[-rw-r--r--] | scripts/vim2pygments.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/vim2pygments.py b/scripts/vim2pygments.py index 80f0ada2..42af0bbe 100644..100755 --- a/scripts/vim2pygments.py +++ b/scripts/vim2pygments.py @@ -11,10 +11,12 @@ :license: BSD, see LICENSE for details. """ +from __future__ import print_function + import sys import re from os import path -from cStringIO import StringIO +from io import StringIO split_re = re.compile(r'(?<!\\)\s+') @@ -765,7 +767,7 @@ TOKENS = { } TOKEN_TYPES = set() -for token in TOKENS.itervalues(): +for token in TOKENS.values(): if not isinstance(token, tuple): token = (token,) for token in token: @@ -836,7 +838,7 @@ def find_colors(code): colors['Normal']['bgcolor'] = bg_color color_map = {} - for token, styles in colors.iteritems(): + for token, styles in colors.items(): if token in TOKENS: tmp = [] if styles.get('noinherit'): @@ -879,7 +881,7 @@ class StyleWriter(object): def write(self, out): self.write_header(out) default_token, tokens = find_colors(self.code) - tokens = tokens.items() + tokens = list(tokens.items()) tokens.sort(lambda a, b: cmp(len(a[0]), len(a[1]))) bg_color = [x[3:] for x in default_token.split() if x.startswith('bg:')] if bg_color: @@ -916,14 +918,14 @@ def convert(filename, stream=None): def main(): if len(sys.argv) != 2 or sys.argv[1] in ('-h', '--help'): - print 'Usage: %s <filename.vim>' % sys.argv[0] + print('Usage: %s <filename.vim>' % sys.argv[0]) return 2 if sys.argv[1] in ('-v', '--version'): - print '%s %s' % (SCRIPT_NAME, SCRIPT_VERSION) + print('%s %s' % (SCRIPT_NAME, SCRIPT_VERSION)) return filename = sys.argv[1] if not (path.exists(filename) and path.isfile(filename)): - print 'Error: %s not found' % filename + print('Error: %s not found' % filename) return 1 convert(filename, sys.stdout) sys.stdout.write('\n') |