Commit c1424e18 authored by Andreas Tille's avatar Andreas Tille

New upstream version 0.10.5

parent 1928e1a2
Metadata-Version: 1.1
Name: rope
Version: 0.10.2
Version: 0.10.5
Summary: a python refactoring library...
Home-page: http://rope.sf.net/
Home-page: https://github.com/python-rope/rope
Author: Ali Gholami Rudi
Author-email: aligrudi@users.sourceforge.net
License: GNU GPL
Description:
**Note:** *Please note that this project has been moved to* `GitHub python-rope / rope`_
.. _GitHub python-rope / rope: https://github.com/python-rope/rope
......@@ -23,16 +21,15 @@ Description:
`Rope`_ is a python refactoring library.
.. _`rope`: http://rope.sf.net/
.. _`rope`: https://github.com/python-rope/rope
New Features
Notes
============
* Under new management! Matěj Cepl <mcepl@cepl.eu> takes it hesitantly
over
* Merged all availables pull requests and patches to the main codebase
* Tests are green again
* Nick Smith <nicks@fastmail.fm> takes over maintaining rope. Many thanks to
Matěj Cepl for his work maintaining rope for the past few years!!
* Full python3 support is in progress... stay tuned
Platform: UNKNOWN
......@@ -45,4 +42,11 @@ Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development
**Note:** *Please note that this project has been moved to* `GitHub python-rope / rope`_
.. _GitHub python-rope / rope: https://github.com/python-rope/rope
......@@ -14,16 +12,15 @@ Overview
`Rope`_ is a python refactoring library.
.. _`rope`: http://rope.sf.net/
.. _`rope`: https://github.com/python-rope/rope
New Features
Notes
============
* Under new management! Matěj Cepl <mcepl@cepl.eu> takes it hesitantly
over
* Merged all availables pull requests and patches to the main codebase
* Tests are green again
* Nick Smith <nicks@fastmail.fm> takes over maintaining rope. Many thanks to
Matěj Cepl for his work maintaining rope for the past few years!!
* Full python3 support is in progress... stay tuned
Getting Started
===============
......@@ -51,14 +48,15 @@ googlegroups.com`_.
License
=======
This program is under the terms of GPL (GNU General Public License).
Have a look at ``COPYING`` file for more information.
This program is under the terms of GPL v2 (GNU General Public License).
Have a look at `COPYING`_ for more information.
.. _`docs/rope.rst`: docs/rope.html
.. _`docs/overview.rst`: docs/overview.html
.. _`docs/contributing.rst`: docs/contributing.html
.. _`docs/library.rst`: docs/library.html
.. _`COPYING`: COPYING
.. image:: https://secure.travis-ci.org/python-rope/rope.png
:alt: Build Status
......@@ -3,19 +3,19 @@
======================
Get Involved!
=============
Getting Involved!
=================
Rope's main goal is being a good refactoring tool for python. It also
provides some IDE helpers. If you like to contribute, you're welcome!
provides some IDE helpers. If you would like to contribute, you're
welcome to!
How to Help Rope?
=================
Rope mailing list is `rope-dev (at) googlegroups.com`_. You can send
a mail to ``rope-dev-subscribe (at) googlegroups [dot] com`` to
subscribe.
Rope's mailing list is `rope-dev (at) googlegroups.com`_. Click the
"Join group to post" button to subscribe. Then:
* Use rope
* Send bug reports and request features
......@@ -28,8 +28,8 @@ subscribe.
Wish List
=========
You are welcome to send your patches to `rope-dev (at)
googlegroups.com`_ mailing list. Here is only a list of suggestions.
You are welcome to send your patches to the `rope-dev (at)
googlegroups.com`_ mailing list. Here is a list of suggestions.
Issues
------
......@@ -78,12 +78,8 @@ more information.
Source Repository
=================
Rope uses Mercurial_ CMS:
* Rope main branch: http://bitbucket.org/agr/rope
* Rope py3k branch: http://bitbucket.org/agr/rope_py3k
.. _Mercurial: http://selenic.com/mercurial
Rope uses GitHub_. The repository exists at
`https://github.com/python-rope/rope`_.
Submitting patches
......@@ -91,11 +87,21 @@ Submitting patches
Patches are welcome.
Patch style
-----------
Programming Style
-----------------
* Follow :PEP:`8`.
* Use four spaces for indentation.
* Include good unit-tests if possible.
* Include good unit-tests when appropriate.
* Rope test suite should pass after patching
* Use ``hg export`` format to preserve your identity
Sending Patches
---------------
Follow the instructions on GitHub_ on how to setup Git and fork the
`python-rope/rope`_ repository. Once your changes are ready, send a
`pull request`_ for review.
.. _GitHub: http://github.com/
.. _`python-rope/rope`: https://github.com/python-rope/rope
.. _`pull request`: https://help.github.com/articles/using-pull-requests
This diff is collapsed.
This diff is collapsed.
......@@ -44,6 +44,7 @@ Features implemented so far:
* Static and dynamic object analysis
* Handling built-in container types
* Saving object information on disk and validating them
* Type hints using docstring or type comments PEP 0484
For more information see `overview.rst`_.
......
Metadata-Version: 1.1
Name: rope
Version: 0.10.5
Summary: a python refactoring library...
Home-page: https://github.com/python-rope/rope
Author: Ali Gholami Rudi
Author-email: aligrudi@users.sourceforge.net
License: GNU GPL
Description:
.. _GitHub python-rope / rope: https://github.com/python-rope/rope
========================================
rope, a python refactoring library ...
========================================
Overview
========
`Rope`_ is a python refactoring library.
.. _`rope`: https://github.com/python-rope/rope
Notes
============
* Nick Smith <nicks@fastmail.fm> takes over maintaining rope. Many thanks to
Matěj Cepl for his work maintaining rope for the past few years!!
* Full python3 support is in progress... stay tuned
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Classifier: Environment :: X11 Applications
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: MacOS X
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development
COPYING
MANIFEST.in
README.rst
setup.py
docs/contributing.rst
docs/done.rst
docs/library.rst
docs/overview.rst
docs/rope.rst
docs/dev/issues.rst
docs/dev/todo.rst
rope/__init__.py
rope.egg-info/PKG-INFO
rope.egg-info/SOURCES.txt
rope.egg-info/dependency_links.txt
rope.egg-info/top_level.txt
rope/base/__init__.py
rope/base/arguments.py
rope/base/ast.py
rope/base/astutils.py
rope/base/builtins.py
rope/base/change.py
rope/base/codeanalyze.py
rope/base/default_config.py
rope/base/evaluate.py
rope/base/exceptions.py
rope/base/fscommands.py
rope/base/history.py
rope/base/libutils.py
rope/base/prefs.py
rope/base/project.py
rope/base/pycore.py
rope/base/pynames.py
rope/base/pynamesdef.py
rope/base/pyobjects.py
rope/base/pyobjectsdef.py
rope/base/pyscopes.py
rope/base/resourceobserver.py
rope/base/resources.py
rope/base/simplify.py
rope/base/stdmods.py
rope/base/taskhandle.py
rope/base/worder.py
rope/base/oi/__init__.py
rope/base/oi/doa.py
rope/base/oi/memorydb.py
rope/base/oi/objectdb.py
rope/base/oi/objectinfo.py
rope/base/oi/runmod.py
rope/base/oi/soa.py
rope/base/oi/soi.py
rope/base/oi/transform.py
rope/base/oi/type_hinting/__init__.py
rope/base/oi/type_hinting/evaluate.py
rope/base/oi/type_hinting/factory.py
rope/base/oi/type_hinting/interfaces.py
rope/base/oi/type_hinting/utils.py
rope/base/oi/type_hinting/providers/__init__.py
rope/base/oi/type_hinting/providers/composite.py
rope/base/oi/type_hinting/providers/docstrings.py
rope/base/oi/type_hinting/providers/inheritance.py
rope/base/oi/type_hinting/providers/interfaces.py
rope/base/oi/type_hinting/providers/numpydocstrings.py
rope/base/oi/type_hinting/providers/pep0484_type_comments.py
rope/base/oi/type_hinting/resolvers/__init__.py
rope/base/oi/type_hinting/resolvers/composite.py
rope/base/oi/type_hinting/resolvers/interfaces.py
rope/base/oi/type_hinting/resolvers/types.py
rope/base/utils/__init__.py
rope/base/utils/datastructures.py
rope/base/utils/pycompat.py
rope/contrib/__init__.py
rope/contrib/autoimport.py
rope/contrib/changestack.py
rope/contrib/codeassist.py
rope/contrib/finderrors.py
rope/contrib/findit.py
rope/contrib/fixmodnames.py
rope/contrib/fixsyntax.py
rope/contrib/generate.py
rope/refactor/__init__.py
rope/refactor/change_signature.py
rope/refactor/encapsulate_field.py
rope/refactor/extract.py
rope/refactor/functionutils.py
rope/refactor/inline.py
rope/refactor/introduce_factory.py
rope/refactor/introduce_parameter.py
rope/refactor/localtofield.py
rope/refactor/method_object.py
rope/refactor/move.py
rope/refactor/multiproject.py
rope/refactor/occurrences.py
rope/refactor/patchedast.py
rope/refactor/rename.py
rope/refactor/restructure.py
rope/refactor/similarfinder.py
rope/refactor/sourceutils.py
rope/refactor/suites.py
rope/refactor/topackage.py
rope/refactor/usefunction.py
rope/refactor/wildcards.py
rope/refactor/importutils/__init__.py
rope/refactor/importutils/actions.py
rope/refactor/importutils/importinfo.py
rope/refactor/importutils/module_imports.py
ropetest/__init__.py
ropetest/advanced_oi_test.py
ropetest/builtinstest.py
ropetest/codeanalyzetest.py
ropetest/historytest.py
ropetest/objectdbtest.py
ropetest/objectinfertest.py
ropetest/projecttest.py
ropetest/pycoretest.py
ropetest/pyscopestest.py
ropetest/runmodtest.py
ropetest/simplifytest.py
ropetest/testutils.py
ropetest/type_hinting_test.py
ropetest/contrib/__init__.py
ropetest/contrib/autoimporttest.py
ropetest/contrib/changestacktest.py
ropetest/contrib/codeassisttest.py
ropetest/contrib/finderrorstest.py
ropetest/contrib/findittest.py
ropetest/contrib/fixmodnamestest.py
ropetest/contrib/generatetest.py
ropetest/refactor/__init__.py
ropetest/refactor/change_signature_test.py
ropetest/refactor/extracttest.py
ropetest/refactor/importutilstest.py
ropetest/refactor/inlinetest.py
ropetest/refactor/movetest.py
ropetest/refactor/multiprojecttest.py
ropetest/refactor/patchedasttest.py
ropetest/refactor/renametest.py
ropetest/refactor/restructuretest.py
ropetest/refactor/similarfindertest.py
ropetest/refactor/suitestest.py
ropetest/refactor/usefunctiontest.py
\ No newline at end of file
"""rope, a python refactoring library"""
INFO = __doc__
VERSION = '0.10.2'
VERSION = '0.10.5'
COPYRIGHT = """\
Copyright (C) 2015-2016 Nicholas Smith
Copyright (C) 2014-2015 Matej Cepl
Copyright (C) 2006-2012 Ali Gholami Rudi
Copyright (C) 2009-2012 Anton Gritsay
......
......@@ -3,18 +3,23 @@ from _ast import *
from rope.base import fscommands
try:
unicode
except NameError:
unicode = str
def parse(source, filename='<string>'):
# NOTE: the raw string should be given to `compile` function
if isinstance(source, unicode):
source = fscommands.unicode_to_file_data(source)
if '\r' in source:
source = source.replace('\r\n', '\n').replace('\r', '\n')
if not source.endswith('\n'):
source += '\n'
if b'\r' in source:
source = source.replace(b'\r\n', b'\n').replace(b'\r', b'\n')
if not source.endswith(b'\n'):
source += b'\n'
try:
return compile(source, filename, 'exec', _ast.PyCF_ONLY_AST)
except (TypeError, ValueError), e:
except (TypeError, ValueError) as e:
error = SyntaxError()
error.lineno = 1
error.filename = filename
......
......@@ -40,6 +40,9 @@ class _NodeNameCollector(object):
def _Name(self, node):
self._add_node(node)
def _ExceptHandler(self, node):
self.names.append((node.name, []))
def _Tuple(self, node):
new_levels = []
if self.levels is not None:
......
"""This module trys to support builtin types and functions."""
import inspect
try:
raw_input
except NameError:
raw_input = input
import rope.base.evaluate
from rope.base import pynames, pyobjects, arguments, utils, ast
from rope.base.utils import pycompat
from rope.base import pynames, pyobjects, arguments, utils
class BuiltinModule(pyobjects.AbstractModule):
......@@ -32,7 +37,7 @@ class BuiltinModule(pyobjects.AbstractModule):
result.update(self.initial)
if self.pycore is not None:
submodules = self.pycore._builtin_submodules(self.name)
for name, module in submodules.iteritems():
for name, module in submodules.items():
result[name] = rope.base.builtins.BuiltinName(module)
return result
......@@ -82,6 +87,9 @@ class BuiltinClass(_BuiltinElement, pyobjects.AbstractClass):
result.update(self.initial)
return result
def get_module(self):
return builtins
class BuiltinFunction(_BuiltinElement, pyobjects.AbstractFunction):
......@@ -266,7 +274,10 @@ class List(BuiltinClass):
# Getting methods
collector('__getitem__', function=self._list_get)
collector('pop', function=self._list_get)
collector('__getslice__', function=self._self_get)
try:
collector('__getslice__', function=self._list_get)
except AttributeError:
pass
super(List, self).__init__(list, collector.attributes)
......@@ -290,6 +301,10 @@ class List(BuiltinClass):
def _list_get(self, context):
if self.holding is not None:
args = context.get_arguments(['self', 'key'])
if (len(args) > 1 and args[1] is not None and
args[1].get_type() == builtins['slice'].get_object()):
return get_list(self.holding)
return self.holding
return context.get_per_name()
......@@ -407,7 +422,7 @@ class Tuple(BuiltinClass):
if objects:
first = objects[0]
attributes = {
'__getitem__': BuiltinName(BuiltinFunction(first)),
'__getitem__': BuiltinName(BuiltinFunction(first)), # TODO: add slice support
'__getslice__':
BuiltinName(BuiltinFunction(pyobjects.PyObject(self))),
'__new__': BuiltinName(BuiltinFunction(function=self._new_tuple)),
......@@ -487,14 +502,21 @@ class Str(BuiltinClass):
collector = _AttributeCollector(str)
collector('__iter__', get_iterator(self_object), check_existence=False)
self_methods = ['__getitem__', '__getslice__', 'capitalize', 'center',
'decode', 'encode', 'expandtabs', 'join', 'ljust',
self_methods = ['__getitem__', 'capitalize', 'center',
'encode', 'expandtabs', 'join', 'ljust',
'lower', 'lstrip', 'replace', 'rjust', 'rstrip',
'strip', 'swapcase', 'title', 'translate', 'upper',
'zfill']
for method in self_methods:
collector(method, self_object)
py2_self_methods = ["__getslice__", "decode"]
for method in py2_self_methods:
try:
collector(method, self_object)
except AttributeError:
pass
for method in ['rsplit', 'split', 'splitlines']:
collector(method, get_list(self_object))
......@@ -568,7 +590,7 @@ class File(BuiltinClass):
attributes = {}
def add(name, returned=None, function=None):
builtin = getattr(file, name, None)
builtin = getattr(open, name, None)
attributes[name] = BuiltinName(
BuiltinFunction(returned=returned, function=function,
builtin=builtin))
......@@ -578,7 +600,7 @@ class File(BuiltinClass):
for method in ['close', 'flush', 'lineno', 'isatty', 'seek', 'tell',
'truncate', 'write', 'writelines']:
add(method)
super(File, self).__init__(file, attributes)
super(File, self).__init__(open, attributes)
get_file = _create_builtin_getter(File)
......@@ -642,12 +664,12 @@ class Lambda(pyobjects.AbstractFunction):
return 'lambda'
def get_param_names(self, special_args=True):
result = [node.id for node in self.arguments.args
if isinstance(node, ast.Name)]
result = [pycompat.get_ast_arg_arg(node) for node in self.arguments.args
if isinstance(node, pycompat.ast_arg_type)]
if self.arguments.vararg:
result.append('*' + self.arguments.vararg)
result.append('*' + pycompat.get_ast_arg_arg(self.arguments.vararg))
if self.arguments.kwarg:
result.append('**' + self.arguments.kwarg)
result.append('**' + pycompat.get_ast_arg_arg(self.arguments.kwarg))
return result
@property
......@@ -787,4 +809,4 @@ _initial_builtins = {
builtin=raw_input)),
}
builtins = BuiltinModule('__builtin__', initial=_initial_builtins)
builtins = BuiltinModule(pycompat.builtins.__name__, initial=_initial_builtins)
......@@ -369,7 +369,7 @@ class _ResourceOperations(object):
fscommands.create_file(resource_path)
else:
fscommands.create_folder(resource_path)
except IOError, e:
except IOError as e:
raise exceptions.RopeError(e)
......
......@@ -19,9 +19,7 @@ class ChangeCollector(object):
if not self.changes:
return None
def compare_changes(change1, change2):
return cmp(change1[:2], change2[:2])
self.changes.sort(compare_changes)
self.changes.sort(key=lambda x: x[:2])
pieces = []
last_changed = 0
for change in self.changes:
......@@ -131,31 +129,31 @@ class _CustomGenerator(object):
i += 1
return result
_main_chars = re.compile(r'[\'|"|#|\\|\[|\]|\{|\}|\(|\)]')
# Matches all backslashes before the token, to detect escaped quotes
_main_tokens = re.compile(r'(\\*)((\'\'\'|"""|\'|")|#|\[|\]|\{|\}|\(|\))')
def _analyze_line(self, line):
char = None
for match in self._main_chars.finditer(line):
char = match.group()
i = match.start()
if char in '\'"':
token = None
for match in self._main_tokens.finditer(line):
prefix = match.group(1)
token = match.group(2)
# Skip any tokens which are escaped
if len(prefix) % 2 == 1:
continue
if token in ["'''", '"""', "'", '"']:
if not self.in_string:
self.in_string = char
if char * 3 == line[i:i + 3]:
self.in_string = char * 3
elif self.in_string == line[i:i + len(self.in_string)] and \
not (i > 0 and line[i - 1] == '\\' and
not (i > 1 and line[i - 2] == '\\')):
self.in_string = token
elif self.in_string == token:
self.in_string = ''
if self.in_string:
continue
if char == '#':
if token == '#':
break
if char in '([{':
if token in '([{':
self.open_count += 1
elif char in ')]}':
elif token in ')]}':
self.open_count -= 1
if line and char != '#' and line.endswith('\\'):
if line and token != '#' and line.endswith('\\'):
self.continuation = True
else:
self.continuation = False
......@@ -177,7 +175,7 @@ class LogicalLineFinder(object):
block_start = get_block_start(self.lines, line_number, indents)
try:
return self._block_logical_line(block_start, line_number)
except IndentationError, e:
except IndentationError as e:
tries += 1
if tries == 5:
raise e
......@@ -222,7 +220,7 @@ class LogicalLineFinder(object):
if line_number <= end:
return (start, end)
last_end = end + 1
except tokenize.TokenError, e:
except tokenize.TokenError as e:
current = e.args[1][0]
return (last_end, max(last_end, current - 1))
return (last_end, None)
......@@ -355,7 +353,7 @@ def count_line_indents(line):
def get_string_pattern():
start = r'(\b[uU]?[rR]?)?'
longstr = r'%s"""(\\.|"(?!"")|\\\n|[^"\\])*"""' % start
shortstr = r'%s"(\\.|[^"\\\n])*"' % start
shortstr = r'%s"(\\.|\\\n|[^"\\])*"' % start
return '|'.join([longstr, longstr.replace('"', "'"),
shortstr, shortstr.replace('"', "'")])
......
# The default ``config.py``
# flake8: noqa
def set_prefs(prefs):
......@@ -79,6 +80,32 @@ def set_prefs(prefs):
# appear in the importing namespace.
prefs['ignore_bad_imports'] = False
# If `True`, rope will insert new module imports as
# `from <package> import <module>` by default.
prefs['prefer_module_from_imports'] = False
# If `True`, rope will transform a comma list of imports into
# multiple separate import statements when organizing
# imports.
prefs['split_imports'] = False
# If `True`, rope will remove all top-level import statements and
# reinsert them at the top of the module when making changes.
prefs['pull_imports_to_top'] = True
# If `True`, rope will sort imports alphabetically by module name instead of
# alphabetically by import statement, with from imports after normal
# imports.
prefs['sort_imports_alphabetically'] = False
# Location of implementation of rope.base.oi.type_hinting.interfaces.ITypeHintingFactory
# In general case, you don't have to change this value, unless you're an rope expert.
# Change this value to inject you own implementations of interfaces
# listed in module rope.base.oi.type_hinting.providers.interfaces
# For example, you can add you own providers for Django Models, or disable the search
# type-hinting in a class hierarchy, etc.
prefs['type_hinting_factory'] = 'rope.base.oi.type_hinting.factory.default_type_hinting_factory'
def project_opened(project):
"""This function is called after opening the project"""
......
......@@ -2,6 +2,7 @@ import rope.base.builtins
import rope.base.pynames
import rope.base.pyobjects
from rope.base import ast, astutils, exceptions, pyobjects, arguments, worder
from rope.base.utils import pycompat
BadIdentifierError = exceptions.BadIdentifierError
......@@ -290,7 +291,11 @@ class StatementEvaluator(object):
self._call_function(node.value, '__getitem__',
[node.slice.value])
elif isinstance(node.slice, ast.Slice):
self._call_function(node.value, '__getslice__')
self._call_function(node.value, '__getitem__',
[node.slice])