Skip to content

Commit 6cf0c64

Browse files
committed
Fix locale
1 parent 2089fe9 commit 6cf0c64

1 file changed

Lines changed: 37 additions & 28 deletions

File tree

pylibs/pymode.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import locale
2+
13
import vim
24

35

6+
locale.setlocale(locale.LC_CTYPE, "C")
7+
8+
49
def check_file():
510
filename = vim.current.buffer.name
611
checkers = vim.eval('g:pymode_lint_checker').split(',')
@@ -17,32 +22,23 @@ def check_file():
1722
errors += checker(filename)
1823
except SyntaxError, e:
1924
errors.append(dict(
20-
lnum = e.lineno,
21-
col = e.offset,
22-
text = e.args[0]
25+
lnum=e.lineno,
26+
col=e.offset,
27+
text=e.args[0]
2328
))
2429
break
2530
except Exception, e:
2631
print e
2732

2833
for e in errors:
2934
e.update(
30-
col = e.get('col') or '',
31-
text = e.get('text', '').replace("'", "\"").split('\n')[0],
32-
filename = filename,
33-
bufnr = vim.current.buffer.number,
35+
col=e.get('col') or '',
36+
text=e.get('text', '').replace("'", "\"").split('\n')[0],
37+
filename=filename,
38+
bufnr=vim.current.buffer.number,
3439
)
3540

36-
def ignore_error(e):
37-
for s in select:
38-
if e['text'].startswith(s):
39-
return True
40-
for i in ignore:
41-
if e['text'].startswith(i):
42-
return False
43-
return True
44-
45-
errors = filter(ignore_error, errors)
41+
errors = filter(lambda e: _ignore_error(e, select, ignore), errors)
4642
errors = sorted(errors, key=lambda x: x['lnum'])
4743

4844
vim.command(('let b:qf_list = %s' % repr(errors)).replace('\': u', '\': '))
@@ -54,7 +50,7 @@ def mccabe(filename):
5450

5551

5652
def pep8(filename):
57-
_ = PEP8 or _init_pep8()
53+
PEP8 or _init_pep8()
5854
checker = PEP8['module'].Checker(filename)
5955
checker.check_all()
6056
return checker.errors
@@ -64,7 +60,7 @@ def pylint(filename):
6460

6561
import StringIO
6662
from logilab.astng.builder import MANAGER
67-
_ = PYLINT or _init_pylint()
63+
PYLINT or _init_pylint()
6864
linter = PYLINT['lint']
6965

7066
MANAGER.astng_cache.clear()
@@ -85,15 +81,17 @@ def pyflakes(filename):
8581
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
8682
for w in w.messages:
8783
errors.append(dict(
88-
lnum = w.lineno,
89-
col = w.col,
90-
text = w.message % w.message_args,
91-
type = 'E'
84+
lnum=w.lineno,
85+
col=w.col,
86+
text=w.message % w.message_args,
87+
type='E'
9288
))
9389
return errors
9490

9591

9692
PYLINT = dict()
93+
94+
9795
def _init_pylint():
9896

9997
from pylint import lint, checkers
@@ -106,13 +104,12 @@ def __init__(self):
106104
def add_message(self, msg_id, location, msg):
107105
_, _, line, col = location[1:]
108106
self.errors.append(dict(
109-
lnum = line,
110-
col = col,
111-
text = "%s %s" % (msg_id, msg),
112-
type = msg_id[0]
107+
lnum=line,
108+
col=col,
109+
text="%s %s" % (msg_id, msg),
110+
type=msg_id[0]
113111
))
114112

115-
116113
PYLINT['lint'] = lint.PyLinter()
117114
PYLINT['re'] = re.compile('^(?:.:)?[^:]+:(\d+): \[([EWRCI]+)[^\]]*\] (.*)$')
118115

@@ -125,6 +122,8 @@ def add_message(self, msg_id, location, msg):
125122

126123

127124
PEP8 = dict()
125+
126+
128127
def _init_pep8():
129128

130129
import pep8 as p8
@@ -159,3 +158,13 @@ class _PEP8Options(object):
159158

160159
PEP8['init'] = True
161160
PEP8['module'] = p8
161+
162+
163+
def _ignore_error(e, select, ignore):
164+
for s in select:
165+
if e['text'].startswith(s):
166+
return True
167+
for i in ignore:
168+
if e['text'].startswith(i):
169+
return False
170+
return True

0 commit comments

Comments
 (0)