Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26bba03

Browse files
committed
Merge branch 'release/0.7.1b'
2 parents4f4ecbd +df0d73d commit26bba03

File tree

171 files changed

+185
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+185
-96
lines changed

‎Changelog.rst

Lines changed: 1 addition & 1 deletion

‎Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
PYMODE =$(CURDIR)/pymode
2+
LIBS =$(PYMODE)/libs
3+
PYLAMA =$(LIBS)/pylama
4+
15
.PHONY: clean
26
clean:
37
find. -name"*.pyc" -delete
@@ -9,6 +13,12 @@ test:
913

1014
.PHONY: pylama
1115
pylama:
12-
rm -rf pylibs/pylama
13-
cp -r~/Dropbox/projects/pylama/pylama pylibs/pylama
14-
cp -r~/Dropbox/projects/pylama/plugins/pylama_pylint/pylama_pylint/ pylibs/pylama/lint/pylama_pylint
16+
rm -rf$(PYLAMA)
17+
make$(PYLAMA)
18+
make$(PYLAMA)/lint/pylama_pylint
19+
20+
$(PYLAMA):
21+
cp -r~/Dropbox/projects/pylama/pylama$(PYLAMA)
22+
23+
$(PYLAMA)/lint/pylama_pylint:
24+
cp -r~/Dropbox/projects/pylama/plugins/pylama_pylint/pylama_pylint/$(PYLAMA)/lint/pylama_pylint

‎autoload/pymode/lint.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ fun! pymode#lint#check() "{{{
4646

4747
letb:pymode_errors= {}
4848

49-
if!pymode#save()
50-
return0
51-
endif
52-
5349
callpymode#wide_message('Code checking is running ...')
5450

5551
PymodePythoncode_check()

‎doc/pymode.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____)~
77

88

9-
Version: 0.7.0b
9+
Version: 0.7.1b
1010

1111
==============================================================================
1212
CONTENTS*pymode-contents*

‎ftplugin/python/pymode.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ if !pymode#default('g:pymode_init', 1)
77
callpymode#init(expand('<sfile>:p:h:h:h'),g:pymode_paths)
88
callpymode#virtualenv#init()
99
callpymode#breakpoint#init()
10+
PymodePython from pymode.utilsimport patch_paths
11+
PymodePythonpatch_paths()
1012
endif
1113

1214
augrouppymode

‎plugin/pymode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" vi:fdl=1
2-
letg:pymode_version="0.7.0b"
2+
letg:pymode_version="0.7.1b"
33

44
com! PymodeVersionechomsg"Current python-mode version:" .g:pymode_version
55
com! PymodeTroubleshootingcallpymode#troubleshooting#test()

‎pymode/pylama/__init__.pyrenamed to‎pymode/libs/pylama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
"""
77

8-
version_info=2,0,1
8+
version_info=2,0,3
99

1010
__version__=version='.'.join(map(str,version_info))
1111
__project__=__name__

‎pymode/pylama/config.pyrenamed to‎pymode/libs/pylama/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from .importversion
1010
from .coreimportLOGGER,STREAM
11-
from .iniramaimportNamespace
12-
from .lintimportLINTERS
11+
from .libs.iniramaimportNamespace
12+
from .lint.extensionsimportLINTERS
1313

1414

1515
#: A default checkers
@@ -127,6 +127,8 @@ def parse_linters(csp_str):
127127
linter=LINTERS.get(name)
128128
iflinter:
129129
result.append((name,linter))
130+
else:
131+
logging.warn("Linter `%s` not found."%name)
130132
returnresult
131133

132134
parser.add_argument(

‎pymode/pylama/core.pyrenamed to‎pymode/libs/pylama/core.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
importlogging
77
importre
8-
from .lintimportLINTERS
8+
from .lint.extensionsimportLINTERS
99

1010
#: The skip pattern
1111
SKIP_PATTERN=re.compile(r'# *noqa\b',re.I).search
@@ -20,7 +20,9 @@
2020
LOGGER.addHandler(STREAM)
2121

2222

23-
defrun(path,ignore=None,select=None,linters=None,config=None,**meta):
23+
defrun(
24+
path,ignore=None,select=None,linters=None,config=None,code=None,
25+
**meta):
2426
""" Run a code checkers with given params.
2527
2628
:return errors: list of dictionaries with error's information
@@ -29,11 +31,9 @@ def run(path, ignore=None, select=None, linters=None, config=None, **meta):
2931
errors= []
3032
linters=lintersorLINTERS.items()
3133
params=dict(ignore=ignore,select=select)
32-
code=None
3334
try:
34-
withopen(path,'rU')asf:
35-
code=f.read()+'\n\n'
36-
35+
withCodeContext(code,path)asctx:
36+
code=ctx.code
3737
params=prepare_params(
3838
parse_modeline(code),config,ignore=ignore,select=select
3939
)
@@ -78,7 +78,7 @@ def run(path, ignore=None, select=None, linters=None, config=None, **meta):
7878

7979
errors= [erforerinerrorsiffilter_errors(er,**params)]
8080

81-
ifcode:
81+
ifcodeanderrors:
8282
errors=filter_skiplines(code,errors)
8383

8484
returnsorted(errors,key=lambdax:x['lnum'])
@@ -158,3 +158,23 @@ def filter_skiplines(code, errors):
158158
errors= [erforerinerrorsifnoter['lnum']inremoved]
159159

160160
returnerrors
161+
162+
163+
classCodeContext(object):
164+
165+
""" Read file if code is None. """
166+
167+
def__init__(self,code,path):
168+
self.code=code
169+
self.path=path
170+
self._file=None
171+
172+
def__enter__(self):
173+
ifself.codeisNone:
174+
self._file=open(self.path,'rU')
175+
self.code=self._file.read()+'\n\n'
176+
returnself
177+
178+
def__exit__(self):
179+
ifnotself._fileisNone:
180+
self._file.close()

‎pymode/pylama/hook.pyrenamed to‎pymode/libs/pylama/hook.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ def run(command):
2929

3030
defgit_hook():
3131
""" Run pylama after git commit. """
32-
3332
from .mainimportcheck_files
33+
3434
_,files_modified,_=run("git diff-index --cached --name-only HEAD")
3535

3636
options=parse_options()
3737
setup_logger(options)
38-
check_files(
39-
[fforfinmap(str,files_modified)iff.endswith('.py')],options
40-
)
38+
check_files([fforfinmap(str,files_modified)],options)
4139

4240

4341
defhg_hook(ui,repo,node=None,**kwargs):
@@ -53,8 +51,7 @@ def hg_hook(ui, repo, node=None, **kwargs):
5351
iffile_inseenornotop.exists(file_):
5452
continue
5553
seen.add(file_)
56-
iffile_.endswith('.py'):
57-
paths.append(file_)
54+
paths.append(file_)
5855

5956
options=parse_options()
6057
setup_logger(options)

‎pymode/libs/pylama/libs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""" Support libs. """

‎pymode/libs/pylama/libs/importlib.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Backport of importlib.import_module from 3.x."""
2+
# While not critical (and in no way guaranteed!), it would be nice to keep this
3+
# code compatible with Python 2.3.
4+
importsys
5+
6+
def_resolve_name(name,package,level):
7+
"""Return the absolute name of the module to be imported."""
8+
ifnothasattr(package,'rindex'):
9+
raiseValueError("'package' not set to a string")
10+
dot=len(package)
11+
forxinxrange(level,1,-1):
12+
try:
13+
dot=package.rindex('.',0,dot)
14+
exceptValueError:
15+
raiseValueError("attempted relative import beyond top-level "
16+
"package")
17+
return"%s.%s"% (package[:dot],name)
18+
19+
20+
defimport_module(name,package=None):
21+
"""Import a module.
22+
23+
The 'package' argument is required when performing a relative import. It
24+
specifies the package to use as the anchor point from which to resolve the
25+
relative import to an absolute import.
26+
27+
"""
28+
ifname.startswith('.'):
29+
ifnotpackage:
30+
raiseTypeError("relative imports require the 'package' argument")
31+
level=0
32+
forcharacterinname:
33+
ifcharacter!='.':
34+
break
35+
level+=1
36+
name=_resolve_name(name[level:],package,level)
37+
__import__(name)
38+
returnsys.modules[name]
File renamed without changes.

‎pymode/libs/pylama/lint/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
""" Custom module loader. """
2+
3+
4+
classLinter(object):# noqa
5+
6+
""" Abstract class for linter plugin. """
7+
8+
@staticmethod
9+
defallow(path):
10+
""" Check path is relevant for linter.
11+
12+
:return bool:
13+
14+
"""
15+
16+
returnpath.endswith('.py')
17+
18+
@staticmethod
19+
defrun(path,**meta):
20+
""" Method 'run' should be defined. """
21+
22+
raiseNotImplementedError(__doc__)

‎pymode/libs/pylama/lint/extensions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
""" Load extensions. """
2+
3+
fromosimportlistdir,pathasop
4+
5+
6+
CURDIR=op.dirname(__file__)
7+
LINTERS=dict()
8+
PREFIX='pylama_'
9+
10+
try:
11+
fromimportlibimportimport_module
12+
exceptImportError:
13+
from ..libs.importlibimportimport_module
14+
15+
forpinlistdir(CURDIR):
16+
ifp.startswith(PREFIX)andop.isdir(op.join(CURDIR,p)):
17+
name=p[len(PREFIX):]
18+
module=import_module('.lint.%s%s'% (PREFIX,name),'pylama')
19+
LINTERS[name]=getattr(module,'Linter')()
20+
21+
try:
22+
frompkg_resourcesimportiter_entry_points
23+
24+
forentryiniter_entry_points('pylama.linter'):
25+
LINTERS[entry.name]=entry.load()()
26+
exceptImportError:
27+
pass

‎pymode/pylama/lint/pylama_pylint/__init__.pyrenamed to‎pymode/libs/pylama/lint/pylama_pylint/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ==================
55

66

7-
__version__='0.1.0'
7+
__version__='0.1.3'
88
__project__='pylama_pylint'
99
__author__="horneds <horneds@gmail.com>"
1010
__license__="BSD"

‎pymode/pylama/lint/pylama_pylint/main.pyrenamed to‎pymode/libs/pylama/lint/pylama_pylint/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
fromosimportpathasop,environ
44

5-
from..importLinterasBaseLinter# noqa
5+
frompylama.lintimportLinterasBaseLinter# noqa
66

77

88
PYLINT_RC=op.abspath(op.join(op.dirname(__file__),'pylint.rc'))

‎pymode/pylama/lint/pylama_pylint/pylint.rcrenamed to‎pymode/libs/pylama/lint/pylama_pylint/pylint.rc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# http://pylint-messages.wikidot.com/all-codes
44
#
55
# C0103: Invalid name "%s" (should match %s)
6-
# C0111: Missing docstring
76
# E1101: %s %r has no %r member
87
# R0901: Too many ancestors (%s/%s)
98
# R0902: Too many instance attributes (%s/%s)
@@ -15,11 +14,10 @@
1514
# W0142: Used * or ** magic
1615
# W0221: Arguments number differs from %s method
1716
# W0232: Class has no __init__ method
18-
# W0401: Wildcard import %s
1917
# W0613: Unused argument %r
2018
# W0631: Using possibly undefined loop variable %r
2119
#
22-
disable = C0103,C0111,E1101,R0901,R0902,R0903,R0904,R0913,R0915,W0141,W0142,W0221,W0232,W0401,W0613,W0631
20+
disable = C0103,E1101,R0901,R0902,R0903,R0904,R0913,R0915,W0141,W0142,W0221,W0232,W0613,W0631
2321

2422
[TYPECHECK]
2523
generated-members = REQUEST,acl_users,aq_parent,objects,DoesNotExist,_meta,status_code,content,context

‎pymode/pylama/main.pyrenamed to‎pymode/libs/pylama/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ def shell(args=None, error=True):
3737
ifop.isdir(options.path):
3838
paths= []
3939
forroot,_,filesinwalk(options.path):
40-
paths+= [
41-
op.relpath(op.join(root,f),CURDIR)
42-
forfinfiles
43-
ifany(l.allow(f)for_,linoptions.linters)]
40+
paths+= [op.relpath(op.join(root,f),CURDIR)forfinfiles]
4441

4542
returncheck_files(paths,options,error=error)
4643

@@ -63,6 +60,13 @@ def check_files(paths, options, rootpath=None, error=True):
6360

6461
work_paths= []
6562
forpathinpaths:
63+
64+
ifnotany(l.allow(path)for_,linoptions.linters):
65+
continue
66+
67+
ifnotop.exists(path):
68+
continue
69+
6670
ifoptions.skipandany(p.match(path)forpinoptions.skip):
6771
LOGGER.info('Skip path: %s',path)
6872
continue

‎pymode/pylama/tasks.pyrenamed to‎pymode/libs/pylama/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def async_check_files(paths, options, rootpath=None):
7979
returnerrors
8080

8181

82-
defcheck_path(path,options=None,rootpath=None,**meta):
82+
defcheck_path(path,options=None,rootpath=None,code=None,**meta):
8383
""" Check path.
8484
8585
:return list: list of errors
@@ -99,7 +99,7 @@ def check_path(path, options=None, rootpath=None, **meta):
9999
forerrorinrun(
100100
path,ignore=options.ignore,select=options.select,
101101
linters=options.linters,complexity=options.complexity,
102-
config=config,**meta):
102+
config=config,code=code,**meta):
103103
try:
104104
error['rel']=op.relpath(error['filename'],rootpath)
105105
error['col']=error.get('col',1)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎pymode/lint.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
defcode_check():
1010
""" Run pylama and check current file. """
1111

12-
from.pylama.mainimportparse_options
13-
from.pylama.tasksimportcheck_path
12+
frompylama.mainimportparse_options
13+
frompylama.tasksimportcheck_path
1414
importjson
1515

1616
b=vim.current.buffer
@@ -31,8 +31,10 @@ def code_check():
3131
vim.command('return')
3232
returnFalse
3333

34+
code='\n'.join(vim.current.buffer)
35+
3436
withsilence_stderr():
35-
errors=check_path(path,options=options)
37+
errors=check_path(path,options=options,code=code)
3638
sort_rules=vim.eval('g:pymode_lint_sort')
3739

3840
defsort(e):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp