Skip to content

Commit

Permalink
completed merge, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianEberius committed Jun 17, 2010
1 parent ec67571 commit 02db4fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.pyc
Support/lib/pydevd
.ropeproject
16 changes: 7 additions & 9 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
**RopeMate.tmbundle**
===========================

Integrates the Python refactoring/completion framework Rope with Textmate
Integrates the Python refactoring/completion framework Rope with Textmate.
Screenshots and more info can be found at the project's [GitHub page](http://specialunderwear.github.com/RopeMate.tmbundle/).

Many thanks to Github user [specialunderwear](http://github.com/specialunderwear) for his contributions!

Copyright (C) 2010 Julian Eberius

CONFIGURATION
-------------
Expand All @@ -18,13 +23,6 @@ If you are doing django development, it might help to set the `DJANGO_SETTINGS_M
# Do whatever you like here!
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

You have to install rope somewhere in your python path:

pip install rope

Copyright (C) 2010 Julian Eberius

Screenshots and more info can be found at the project's [GitHub page](http://specialunderwear.github.com/RopeMate.tmbundle/).

License:
This program is free software; you can redistribute it and/or modify
Expand All @@ -46,4 +44,4 @@ Screenshots and more info can be found at the project's [GitHub page](http://spe
EXTERNAL LICENSES
-----------------
This project uses code from other open source projects (Rope)
which include licenses of their own.
which may include licenses of their own.
25 changes: 12 additions & 13 deletions Support/bin/refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from rope.refactor.localtofield import LocalToField

import ropemate
from ropemate import ropecontext
from ropemate.utils import *

def autocomplete():
Expand Down Expand Up @@ -248,8 +247,7 @@ def find_last_import_line(lines):
import_name = re.search(r'match = (.*);', out).group(1)

typed_len = len(word)
full_name = import_from_mod_name+"."+import_name
code = code[:offset-typed_len] + import_name + code[offset:]
code = context.input[:offset-typed_len] + import_name + context.input[offset:]
lines = code.split("\n")
idx = find_last_import_line(lines)
new_line = "from "+import_from_mod_name+" import "+import_name
Expand All @@ -258,21 +256,22 @@ def find_last_import_line(lines):
result = "\n".join(lines)
except Exception, e:
tooltip(e)
return context.input
return result

def local_to_field():
project, resource, code = init_from_env()
try:
offset = caret_position(code)
operation = LocalToField(project, resource, offset)
with ropemate.context as context:
try:
offset = caret_position(context.input)
operation = LocalToField(context.project, context.resource, offset)

changes = operation.get_changes()
result = changes.changes[0].new_contents
except Exception, e:
tooltip(e)
return code
changes = operation.get_changes()
result = changes.changes[0].new_contents
except Exception, e:
tooltip(e)
return context.input

return result
return result

def main():
operation = {'extract_method' : extract_method,
Expand Down
11 changes: 10 additions & 1 deletion Support/lib/ropemate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ def find_unindexed_files(directory):

def from_without_import():
line = os.environ.get('TM_CURRENT_LINE')
return line.find('from ') != -1 and line.find(' import ') == -1
return line.find('from ') != -1 and line.find(' import ') == -1

def detect_virtualenv():
file_path = os.environ['TM_FILEPATH']
path,_ = os.path.split(file_path)
while path:
if os.path.exists(os.path.join(path,".Python")):
return path
path,_ = os.path.split(path)
return ""

0 comments on commit 02db4fe

Please sign in to comment.