Home Download Buy Blog Forum Support

Python Completion and GotoDefinition plugin using Rope

Re: Python Completion and GotoDefinition plugin using Rope

Postby ehamiter on Tue Jan 10, 2012 5:32 pm

This a fantastic plugin. Thanks!
ehamiter
 
Posts: 67
Joined: Wed Apr 27, 2011 2:42 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby willy1234x1 on Sat Jan 14, 2012 8:03 pm

How does this compare to SublimeCodeIntel? Or are they compatible together?
willy1234x1
 
Posts: 32
Joined: Thu Dec 22, 2011 7:55 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby willy1234x1 on Fri Jan 20, 2012 8:39 pm

Really though, is this compatible with SublimeCodeIntel? Can someone confirm this? Or just give me an overview of this vs SublimeCodeIntel?
willy1234x1
 
Posts: 32
Joined: Thu Dec 22, 2011 7:55 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby natchiketa on Sun Feb 12, 2012 11:56 pm

Hi there,

I've been using SublimeRope pretty much since I first discovered ST2 a couple of weeks ago, and many thanks to Julian Eberius for such an amazing contribution—(I hope you can buy a beer with €5)

Is it possible to get relative paths to work in .ropeproject/config.py? I often work on my work box and my home box, and while they are both Macs, I have different usernames and keep my projects in different paths, so I'd love to be able to define the directories for 'source_folders' and 'python_path' as from the root of the project, but everything I've tried seems to fail (other than absolute paths, which I then have to change whenever I switch workstations).

I tried using os.listdir() from the project_opened method, to see where config.py is running from, and it seems like it's running from the root directory of the machine...

I suppose a heavy-handed approach would be to write a bash script, or something else like this, which will return the actual directory where the project resides (be it at home, work, etc), and then pass that to config.py so it can use it as a prefix. Is there anything simpler that I'm missing?

The importance of this more evident when working with a team—I'd love to get the other developers hooked on ST2 :)

Thanks again!
natchiketa
 
Posts: 3
Joined: Sun Feb 12, 2012 5:50 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby astrogee on Fri Feb 17, 2012 8:57 pm

I'm having trouble getting auto imports to work for modules located outside the project. I have added

Code: Select all
prefs.add('python_path', 'C:\\PathToMyOtherProjectsSrc')


in config.py but Rope does not seem to index these directories.I've tried to debug Rope but I'm getting nowhere. Could it be a Windows issue? Is Rope expecting Windows directory paths to be on a different format?
astrogee
 
Posts: 6
Joined: Tue Feb 07, 2012 9:55 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby natchiketa on Mon Mar 12, 2012 10:56 pm

If you read the comments directly above the examples of prefs.add(), you'll see that it says to use / regardless of the platform you're running on.

Hope that helps!
natchiketa
 
Posts: 3
Joined: Sun Feb 12, 2012 5:50 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby agibsonsw on Tue Mar 13, 2012 12:15 am

Does this plugin provide assistance when entering function parameters, or is it simply a word list?
Does it suggest standard Python functions, or only those from the current project?

(I'm a little reluctant to install, and explore it, just to answer these two questions :) )
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby dribble on Tue Mar 13, 2012 1:19 pm

I have been using this plugin along side SublimeCodeIntel with no problem.

Where SublimeCodeIntel will fall short (go-to definition, for instance), this tends to work better, given the required setup (you DID read the readme, right?) to point it to your standard/virtualenv path(s).

That said, are either perfect? No -- but in running comparisons of CodeIntel against KomodoEdit (where the auto-complete engine is pulled from) I get similar results.

Additionally, the refactoring tools in Rope are nice -- when they work.
I haven't taken the time to debug the root cause, but I'm finding it to be a 50/50 shot at success.

-my $.02
dribble
 
Posts: 6
Joined: Sun Mar 04, 2012 9:35 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby schickm on Fri Apr 27, 2012 2:18 pm

natchiketa wrote:... Is it possible to get relative paths to work in .ropeproject/config.py? ...


Here's what I did, using the handy python var __file__ and os.path:

Code: Select all
from os import path
prefs.add('python_path', path.normpath(path.join(path.dirname(path.realpath(__file__)), '../../lib/python2.7/site-packages')))


As you might infer, my config.py is located in /Users/matt/Project/env/project/.ropeproject/config.py, so I have to go up two directories and then traverse back down to site-packages.
schickm
 
Posts: 1
Joined: Fri Apr 27, 2012 2:09 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby shoyer on Wed Jul 11, 2012 12:47 am

I just got started with Sublime Text and have some trouble getting this plugin to work. Here is the error message I get when I try to use "Show Documentation" on highlighted text. Oddly, some other Rope commands (e.g., Go to Global) seem to be working okay. Any ideas?

Code: Select all
Traceback (most recent call last):
  File "./sublime_plugin.py", line 362, in run_
  File "./sublime_rope.py", line 146, in run
    maxfixes=3)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/contrib/codeassist.py", line 59, in get_doc
    pyname = fixer.pyname_at(offset)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/contrib/fixsyntax.py", line 63, in pyname_at
    return new_pyname()
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/contrib/fixsyntax.py", line 61, in new_pyname
    return rope.base.evaluate.eval_location(pymodule, newoffset)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 11, in eval_location
    return eval_location2(pymodule, offset)[1]
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 17, in eval_location2
    return pyname_finder.get_primary_and_pyname_at(offset)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 108, in get_primary_and_pyname_at
    return eval_str2(holding_scope, name)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 44, in eval_str2
    return eval_node2(holding_scope, node)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 30, in eval_node2
    ast.walk(node, evaluator)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 36, in walk
    walk(child, walker)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 36, in walk
    walk(child, walker)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 34, in walk
    return method(node)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 146, in _Attribute
    pyname = eval_node(self.scope, node.value)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 25, in eval_node
    return eval_node2(scope, node)[1]
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 30, in eval_node2
    ast.walk(node, evaluator)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 34, in walk
    return method(node)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 157, in _Call
    primary, pyobject = self._get_primary_and_object_for_node(node.func)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 277, in _get_primary_and_object_for_node
    primary, pyname = eval_node2(self.scope, stmt)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 30, in eval_node2
    ast.walk(node, evaluator)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 34, in walk
    return method(node)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 146, in _Attribute
    pyname = eval_node(self.scope, node.value)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 25, in eval_node
    return eval_node2(scope, node)[1]
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 30, in eval_node2
    ast.walk(node, evaluator)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/ast.py", line 34, in walk
    return method(node)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/evaluate.py", line 143, in _Name
    self.result = self.scope.lookup(node.id)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyscopes.py", line 48, in lookup
    return self.parent._propagated_lookup(name)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyscopes.py", line 62, in _propagated_lookup
    if name in self.get_propagated_names():
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyscopes.py", line 59, in get_propagated_names
    return self.get_names()
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyscopes.py", line 127, in get_names
    result.update(super(GlobalScope, self).get_names())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyscopes.py", line 16, in get_names
    return self.pyobject.get_attributes()
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjects.py", line 196, in get_attributes
    result = dict(self._get_concluded_attributes())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjects.py", line 191, in _get_concluded_attributes
    self.concluded_attributes.set(self._create_concluded_attributes())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 191, in _create_concluded_attributes
    result.update(star_import.get_names())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 534, in get_names
    for name in imported:
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjects.py", line 65, in __iter__
    return iter(self.get_attributes())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjects.py", line 196, in get_attributes
    result = dict(self._get_concluded_attributes())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjects.py", line 191, in _get_concluded_attributes
    self.concluded_attributes.set(self._create_concluded_attributes())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 191, in _create_concluded_attributes
    result.update(star_import.get_names())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 533, in get_names
    imported = self.imported_module.get_object()
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pynames.py", line 130, in get_object
    if self._get_pymodule() is None:
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pynames.py", line 120, in _get_pymodule
    self._current_folder())
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pycore.py", line 84, in get_module
    return self.resource_to_pyobject(module)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pycore.py", line 194, in resource_to_pyobject
    return self.module_cache.get_pymodule(resource, force_errors)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pycore.py", line 320, in get_pymodule
    force_errors=force_errors)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 153, in __init__
    source, node = self._init_source(pycore, source, resource)
  File "/Users/Stephan/Library/Application Support/Sublime Text 2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 182, in _init_source
    raise exceptions.ModuleSyntaxError(filename, e.lineno, e.msg)
rope.base.exceptions.ModuleSyntaxError: Syntax error in file <utils.py> line <127>: invalid syntax
shoyer
 
Posts: 1
Joined: Wed Jul 11, 2012 12:42 am

Previous

Return to Plugin Announcements

Who is online

Users browsing this forum: nadiam02 and 8 guests