From 492f361b79f93a110679ccb7f7e86f4814990dee Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 10 Jan 2014 10:52:53 +0100 Subject: new year in copyright notice --- scripts/check_sources.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/check_sources.py') diff --git a/scripts/check_sources.py b/scripts/check_sources.py index d9e5c2ae..a0bebe27 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -7,7 +7,7 @@ Make sure each Python file has a correct file header including copyright and license information. - :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -30,7 +30,7 @@ def checker(*suffixes, **kwds): name_mail_re = r'[\w ]+(<.*?>)?' -copyright_re = re.compile(r'^ :copyright: Copyright 2006-2013 by ' +copyright_re = re.compile(r'^ :copyright: Copyright 2006-2014 by ' r'the Pygments team, see AUTHORS\.$', re.UNICODE) copyright_2_re = re.compile(r'^ %s(, %s)*[,.]$' % (name_mail_re, name_mail_re), re.UNICODE) -- cgit v1.2.1 From a9169c157a05c82a1b8a7ffb92e7f159fb4ca0f8 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 18 Jan 2014 13:25:15 +0100 Subject: futurizing: move to print_function and "except X as Y" syntax --- scripts/check_sources.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'scripts/check_sources.py') diff --git a/scripts/check_sources.py b/scripts/check_sources.py index a0bebe27..70013dcf 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -10,6 +10,7 @@ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ +from __future__ import print_function import sys, os, re import getopt @@ -46,7 +47,7 @@ misspellings = ["developement", "adress", "verificate", # ALLOW-MISSPELLING def check_syntax(fn, lines): try: compile(''.join(lines), fn, "exec") - except SyntaxError, err: + except SyntaxError as err: yield 0, "not compilable: %s" % err @@ -67,9 +68,9 @@ def check_style_and_encoding(fn, lines): encoding = co.group(1) try: line.decode(encoding) - except UnicodeDecodeError, err: + except UnicodeDecodeError as err: yield lno+1, "not decodable: %s\n Line: %r" % (err, line) - except LookupError, err: + except LookupError as err: yield 0, "unknown encoding: %s" % encoding encoding = 'latin1' @@ -165,7 +166,7 @@ def main(argv): try: gopts, args = getopt.getopt(argv[1:], "vi:") except getopt.GetoptError: - print "Usage: %s [-v] [-i ignorepath]* [path]" % argv[0] + print("Usage: %s [-v] [-i ignorepath]* [path]" % argv[0]) return 2 opts = {} for opt, val in gopts: @@ -178,7 +179,7 @@ def main(argv): elif len(args) == 1: path = args[0] else: - print "Usage: %s [-v] [-i ignorepath]* [path]" % argv[0] + print("Usage: %s [-v] [-i ignorepath]* [path]" % argv[0]) return 2 verbose = '-v' in opts @@ -212,13 +213,13 @@ def main(argv): continue if verbose: - print "Checking %s..." % fn + print("Checking %s..." % fn) try: f = open(fn, 'r') lines = list(f) - except (IOError, OSError), err: - print "%s: cannot open: %s" % (fn, err) + except (IOError, OSError) as err: + print("%s: cannot open: %s" % (fn, err)) num += 1 continue @@ -226,15 +227,15 @@ def main(argv): if not in_pocoo_pkg and checker.only_pkg: continue for lno, msg in checker(fn, lines): - print >>out, "%s:%d: %s" % (fn, lno, msg) + print("%s:%d: %s" % (fn, lno, msg), file=out) num += 1 if verbose: - print + print() if num == 0: - print "No errors found." + print("No errors found.") else: - print out.getvalue().rstrip('\n') - print "%d error%s found." % (num, num > 1 and "s" or "") + print(out.getvalue().rstrip('\n')) + print("%d error%s found." % (num, num > 1 and "s" or "")) return int(num > 0) -- cgit v1.2.1 From b6b690fb833e7031a3008509c1107f7567c065f3 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 18 Jan 2014 13:29:19 +0100 Subject: manual prettifying and small fixes after futurize run --- scripts/check_sources.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/check_sources.py') diff --git a/scripts/check_sources.py b/scripts/check_sources.py index 70013dcf..759fce72 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -10,9 +10,12 @@ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ + from __future__ import print_function -import sys, os, re +import os +import re +import sys import getopt import cStringIO from os.path import join, splitext, abspath -- cgit v1.2.1 From 97703d63f39e6086d497a6a749c9eee3293dcbeb Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 18 Jan 2014 16:44:49 +0100 Subject: Finalize single-source port for Py2.[67] and Py3.3+. --- scripts/check_sources.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'scripts/check_sources.py') diff --git a/scripts/check_sources.py b/scripts/check_sources.py index 759fce72..71aff299 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -13,11 +13,11 @@ from __future__ import print_function +import io import os import re import sys import getopt -import cStringIO from os.path import join, splitext, abspath @@ -71,6 +71,9 @@ def check_style_and_encoding(fn, lines): encoding = co.group(1) try: line.decode(encoding) + except AttributeError: + # Python 3 - encoding was already checked + pass except UnicodeDecodeError as err: yield lno+1, "not decodable: %s\n Line: %r" % (err, line) except LookupError as err: @@ -134,7 +137,7 @@ def check_fileheader(fn, lines): yield 0, "no correct license info" ci = -3 - copyright = [s.decode('utf-8') for s in llist[ci:ci+1]] + copyright = llist[ci:ci+1] while copyright and copyright_2_re.match(copyright[0]): ci -= 1 copyright = llist[ci:ci+1] @@ -188,14 +191,14 @@ def main(argv): verbose = '-v' in opts num = 0 - out = cStringIO.StringIO() + out = io.StringIO() # TODO: replace os.walk run with iteration over output of # `svn list -R`. for root, dirs, files in os.walk(path): - if '.svn' in dirs: - dirs.remove('.svn') + if '.hg' in dirs: + dirs.remove('.hg') if '-i' in opts and abspath(root) in opts['-i']: del dirs[:] continue @@ -230,7 +233,7 @@ def main(argv): if not in_pocoo_pkg and checker.only_pkg: continue for lno, msg in checker(fn, lines): - print("%s:%d: %s" % (fn, lno, msg), file=out) + print(u"%s:%d: %s" % (fn, lno, msg), file=out) num += 1 if verbose: print() -- cgit v1.2.1