import inspect
import os
import re
+import six
import sys
import checkpackagelib.lib_config
for cf in objects:
nwarnings += print_warnings(cf.before())
- for lineno, text in enumerate(open(fname, "r").readlines()):
+ if six.PY3:
+ f = open(fname, "r", errors="surrogateescape")
+ else:
+ f = open(fname, "r")
+ for lineno, text in enumerate(f.readlines()):
nlines += 1
for cf in objects:
nwarnings += print_warnings(cf.check_line(lineno + 1, text))
+ f.close()
for cf in objects:
nwarnings += print_warnings(cf.after())
# See utils/checkpackagelib/readme.txt before editing this file.
-from base import _CheckFunction
+from checkpackagelib.base import _CheckFunction
class ConsecutiveEmptyLines(_CheckFunction):
import re
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines # noqa: F401
-from lib import EmptyLastLine # noqa: F401
-from lib import NewlineAtEof # noqa: F401
-from lib import TrailingSpace # noqa: F401
+from checkpackagelib.base import _CheckFunction
+from checkpackagelib.lib import ConsecutiveEmptyLines # noqa: F401
+from checkpackagelib.lib import EmptyLastLine # noqa: F401
+from checkpackagelib.lib import NewlineAtEof # noqa: F401
+from checkpackagelib.lib import TrailingSpace # noqa: F401
def _empty_or_comment(text):
import re
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines # noqa: F401
-from lib import EmptyLastLine # noqa: F401
-from lib import NewlineAtEof # noqa: F401
-from lib import TrailingSpace # noqa: F401
+from checkpackagelib.base import _CheckFunction
+from checkpackagelib.lib import ConsecutiveEmptyLines # noqa: F401
+from checkpackagelib.lib import EmptyLastLine # noqa: F401
+from checkpackagelib.lib import NewlineAtEof # noqa: F401
+from checkpackagelib.lib import TrailingSpace # noqa: F401
def _empty_line_or_comment(text):
import re
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines # noqa: F401
-from lib import EmptyLastLine # noqa: F401
-from lib import NewlineAtEof # noqa: F401
-from lib import TrailingSpace # noqa: F401
+from checkpackagelib.base import _CheckFunction
+from checkpackagelib.lib import ConsecutiveEmptyLines # noqa: F401
+from checkpackagelib.lib import EmptyLastLine # noqa: F401
+from checkpackagelib.lib import NewlineAtEof # noqa: F401
+from checkpackagelib.lib import TrailingSpace # noqa: F401
class Indent(_CheckFunction):
import re
-from base import _CheckFunction
-from lib import NewlineAtEof # noqa: F401
+from checkpackagelib.base import _CheckFunction
+from checkpackagelib.lib import NewlineAtEof # noqa: F401
class ApplyOrder(_CheckFunction):