Skip to content

Commit 78f9349

Browse files
committed
More logging in debug mode. Fix Rope project initilization
1 parent 5ee74a7 commit 78f9349

File tree

8 files changed

+35
-13
lines changed

8 files changed

+35
-13
lines changed

plugin/pymode.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ call pymode#default('g:pymode_breakpoint_cmd', '')
147147
" Rope support
148148
call pymode#default('g:pymode_rope', 1)
149149

150+
" System plugin variable
151+
call pymode#default('g:pymode_rope_current', '')
152+
150153
" If project hasnt been finded in current working directory, look at parents directory
151154
call pymode#default('g:pymode_rope_lookup_project', 1)
152155

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, 3
8+
version_info = 2, 0, 4
99

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

pymode/libs/pylama/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def parse_linters(csp_str):
128128
if linter:
129129
result.append((name, linter))
130130
else:
131-
logging.warn("Linter `%s` not found." % name)
131+
logging.warn("Linter `%s` not found.", name)
132132
return result
133133

134134
parser.add_argument(

pymode/libs/pylama/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
import logging
77
import re
8+
import sys
89
from .lint.extensions import LINTERS
910

1011
#: The skip pattern
@@ -16,7 +17,7 @@
1617

1718
# Setup a logger
1819
LOGGER = logging.getLogger('pylama')
19-
STREAM = logging.StreamHandler()
20+
STREAM = logging.StreamHandler(sys.stdout)
2021
LOGGER.addHandler(STREAM)
2122

2223

@@ -175,6 +176,9 @@ def __enter__(self):
175176
self.code = self._file.read() + '\n\n'
176177
return self
177178

178-
def __exit__(self):
179+
def __exit__(self, t, value, traceback):
179180
if not self._file is None:
180181
self._file.close()
182+
183+
if t and LOGGER.level == logging.DEBUG:
184+
LOGGER.debug(traceback)

pymode/lint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def code_check():
3131
env.stop()
3232
return False
3333

34+
if env.options.get('debug'):
35+
from pylama.core import LOGGER, logging
36+
LOGGER.setLevel(logging.DEBUG)
37+
3438
with silence_stderr():
3539
errors = check_path(path, options=options, code=env.source)
3640

pymode/rope.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def look_ropeproject(path):
2323
:return str|None: A finded path
2424
2525
"""
26+
env.debug('Look project', path)
2627
p = os.path.abspath(path)
2728

2829
while True:
@@ -31,7 +32,7 @@ def look_ropeproject(path):
3132

3233
new_p = os.path.abspath(os.path.join(p, ".."))
3334
if new_p == p:
34-
return '.'
35+
return path
3536

3637
p = new_p
3738

@@ -279,7 +280,8 @@ def get_ctx(*args, **kwargs):
279280
if resources.get(path):
280281
return resources.get(path)
281282

282-
project_path = os.path.dirname(env.curdir)
283+
project_path = env.curdir
284+
env.debug('Look ctx', project_path)
283285
if env.var('g:pymode_rope_lookup_project', True):
284286
project_path = look_ropeproject(project_path)
285287

@@ -353,8 +355,10 @@ def __init__(self, path, project_path):
353355
self.generate_autoimport_cache()
354356

355357
env.debug('Context init', project_path)
358+
env.message('Init Rope project: %s' % project_path)
356359

357360
def __enter__(self):
361+
env.let('g:pymode_rope_current', self.project.root.real_path)
358362
self.project.validate(self.project.root)
359363
self.resource = libutils.path_to_resource(
360364
self.project, env.curbuf.name, 'file')

pymode/utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@
2121
def silence_stderr():
2222
""" Redirect stderr. """
2323

24-
with threading.Lock():
25-
stderr = sys.stderr
26-
sys.stderr = StringIO()
24+
if DEBUG:
25+
yield
2726

28-
yield
27+
else:
28+
with threading.Lock():
29+
stderr = sys.stderr
30+
sys.stderr = StringIO()
31+
32+
yield
2933

30-
with threading.Lock():
31-
sys.stderr = stderr
34+
with threading.Lock():
35+
sys.stderr = stderr
3236

3337

3438
def patch_paths():

t/rope.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
let g:pymode_rope_completion_bind = 'X'
22
let g:pymode_rope_autoimport = 0
33
let g:pymode_debug = 1
4+
let g:pymode_rope_lookup_project = 0
45

56
source plugin/pymode.vim
67

@@ -16,10 +17,12 @@ describe 'pymode-plugin'
1617
end
1718

1819
it 'pymode rope auto open project in current working directory'
19-
let project_path = '.ropeproject'
20+
let project_path = getcwd() . '/.ropeproject'
2021
Expect isdirectory(project_path) == 0
2122
normal oimporX
2223
Expect getline('.') == 'import'
24+
Expect g:pymode_rope_current == getcwd() . '/'
25+
Expect g:pymode_rope_current . '.ropeproject' == project_path
2326
Expect isdirectory(project_path) == 1
2427
end
2528

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy