Browse files

Fix locale

  • Loading branch information...
1 parent 2089fe9 commit 6cf0c6453c094eef1a7fb195988fdf60a907edc9 @klen committed Mar 13, 2012
Showing with 37 additions and 28 deletions.
  1. +37 −28 pylibs/pymode.py
View
65 pylibs/pymode.py
@@ -1,6 +1,11 @@
+import locale
+
import vim
+locale.setlocale(locale.LC_CTYPE, "C")
+
+
def check_file():
filename = vim.current.buffer.name
checkers = vim.eval('g:pymode_lint_checker').split(',')
@@ -17,32 +22,23 @@ def check_file():
errors += checker(filename)
except SyntaxError, e:
errors.append(dict(
- lnum = e.lineno,
- col = e.offset,
- text = e.args[0]
+ lnum=e.lineno,
+ col=e.offset,
+ text=e.args[0]
))
break
except Exception, e:
print e
for e in errors:
e.update(
- col = e.get('col') or '',
- text = e.get('text', '').replace("'", "\"").split('\n')[0],
- filename = filename,
- bufnr = vim.current.buffer.number,
+ col=e.get('col') or '',
+ text=e.get('text', '').replace("'", "\"").split('\n')[0],
+ filename=filename,
+ bufnr=vim.current.buffer.number,
)
- def ignore_error(e):
- for s in select:
- if e['text'].startswith(s):
- return True
- for i in ignore:
- if e['text'].startswith(i):
- return False
- return True
-
- errors = filter(ignore_error, errors)
+ errors = filter(lambda e: _ignore_error(e, select, ignore), errors)
errors = sorted(errors, key=lambda x: x['lnum'])
vim.command(('let b:qf_list = %s' % repr(errors)).replace('\': u', '\': '))
@@ -54,7 +50,7 @@ def mccabe(filename):
def pep8(filename):
- _ = PEP8 or _init_pep8()
+ PEP8 or _init_pep8()
checker = PEP8['module'].Checker(filename)
checker.check_all()
return checker.errors
@@ -64,7 +60,7 @@ def pylint(filename):
import StringIO
from logilab.astng.builder import MANAGER
- _ = PYLINT or _init_pylint()
+ PYLINT or _init_pylint()
linter = PYLINT['lint']
MANAGER.astng_cache.clear()
@@ -85,15 +81,17 @@ def pyflakes(filename):
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
for w in w.messages:
errors.append(dict(
- lnum = w.lineno,
- col = w.col,
- text = w.message % w.message_args,
- type = 'E'
+ lnum=w.lineno,
+ col=w.col,
+ text=w.message % w.message_args,
+ type='E'
))
return errors
PYLINT = dict()
+
+
def _init_pylint():
from pylint import lint, checkers
@@ -106,13 +104,12 @@ def __init__(self):
def add_message(self, msg_id, location, msg):
_, _, line, col = location[1:]
self.errors.append(dict(
- lnum = line,
- col = col,
- text = "%s %s" % (msg_id, msg),
- type = msg_id[0]
+ lnum=line,
+ col=col,
+ text="%s %s" % (msg_id, msg),
+ type=msg_id[0]
))
-
PYLINT['lint'] = lint.PyLinter()
PYLINT['re'] = re.compile('^(?:.:)?[^:]+:(\d+): \[([EWRCI]+)[^\]]*\] (.*)$')
@@ -125,6 +122,8 @@ def add_message(self, msg_id, location, msg):
PEP8 = dict()
+
+
def _init_pep8():
import pep8 as p8
@@ -159,3 +158,13 @@ class _PEP8Options(object):
PEP8['init'] = True
PEP8['module'] = p8
+
+
+def _ignore_error(e, select, ignore):
+ for s in select:
+ if e['text'].startswith(s):
+ return True
+ for i in ignore:
+ if e['text'].startswith(i):
+ return False
+ return True

0 comments on commit 6cf0c64

Please sign in to comment.