Skip to content

Commit e9bd734

Browse files
committed
Merge branch 'develop' of https://github.com/TFenby/python-mode into TFenby-develop
2 parents 9c8468e + 7cf4eb9 commit e9bd734

Some content is hidden

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

63 files changed

+1332
-800
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ Contributors:
4747
* lee (loyalpartner);
4848
* nixon;
4949
* tramchamploo;
50+
* Tyler Fenby (https://github.com/TFenby)

pymode/libs2/rope/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""rope, a python refactoring library"""
22

33
INFO = __doc__
4-
VERSION = '0.9.4'
4+
VERSION = '0.10.2'
55
COPYRIGHT = """\
66
Copyright (C) 2006-2012 Ali Gholami Rudi
77
Copyright (C) 2009-2012 Anton Gritsay

pymode/libs2/rope/base/arguments.py

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def get_pynames(self, parameters):
7272

7373
def get_instance_pyname(self):
7474
return self.pynames[0]
75+
76+
7577
class MixedArguments(object):
7678

7779
def __init__(self, pyname, arguments, scope):

pymode/libs2/rope/base/builtins.py

+45-22
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ def _get_builtin(*args):
149149
return cls._generated[args]
150150
return _get_builtin
151151

152+
152153
def _create_builtin_getter(cls):
153154
type_getter = _create_builtin_type_getter(cls)
155+
154156
def _get_builtin(*args):
155157
return pyobjects.PyObject(type_getter(*args))
156158
return _get_builtin
@@ -233,7 +235,7 @@ def __call__(self, name, returned=None, function=None,
233235
except AttributeError:
234236
if check_existence:
235237
raise
236-
builtin=None
238+
builtin = None
237239
self.attributes[name] = BuiltinName(
238240
BuiltinFunction(returned=returned, function=function,
239241
argnames=argnames, builtin=builtin))
@@ -252,7 +254,8 @@ def __init__(self, holding=None):
252254
collector('__new__', function=self._new_list)
253255

254256
# Adding methods
255-
collector('append', function=self._list_add, argnames=['self', 'value'])
257+
collector('append', function=self._list_add,
258+
argnames=['self', 'value'])
256259
collector('__setitem__', function=self._list_add,
257260
argnames=['self', 'index', 'value'])
258261
collector('insert', function=self._list_add,
@@ -306,7 +309,6 @@ class Dict(BuiltinClass):
306309
def __init__(self, keys=None, values=None):
307310
self.keys = keys
308311
self.values = values
309-
item = get_tuple(self.keys, self.values)
310312
collector = _AttributeCollector(dict)
311313
collector('__new__', function=self._new_dict)
312314
collector('__setitem__', function=self._dict_add)
@@ -327,7 +329,8 @@ def do_create(holding=None):
327329
if holding is None:
328330
return get_dict()
329331
type = holding.get_type()
330-
if isinstance(type, Tuple) and len(type.get_holding_objects()) == 2:
332+
if isinstance(type, Tuple) and \
333+
len(type.get_holding_objects()) == 2:
331334
return get_dict(*type.get_holding_objects())
332335
return _create_builtin(args, do_create)
333336

@@ -384,7 +387,7 @@ def _self_set(self, context):
384387
if new_dict and isinstance(new_dict.get_object().get_type(), Dict):
385388
args = arguments.ObjectArguments([new_dict])
386389
items = new_dict.get_object()['popitem'].\
387-
get_object().get_returned_object(args)
390+
get_object().get_returned_object(args)
388391
context.save_per_name(items)
389392
else:
390393
holding = _infer_sequence_for_pyname(new_dict)
@@ -405,7 +408,8 @@ def __init__(self, *objects):
405408
first = objects[0]
406409
attributes = {
407410
'__getitem__': BuiltinName(BuiltinFunction(first)),
408-
'__getslice__': BuiltinName(BuiltinFunction(pyobjects.PyObject(self))),
411+
'__getslice__':
412+
BuiltinName(BuiltinFunction(pyobjects.PyObject(self))),
409413
'__new__': BuiltinName(BuiltinFunction(function=self._new_tuple)),
410414
'__iter__': BuiltinName(BuiltinFunction(get_iterator(first)))}
411415
super(Tuple, self).__init__(tuple, attributes)
@@ -485,8 +489,9 @@ def __init__(self):
485489

486490
self_methods = ['__getitem__', '__getslice__', 'capitalize', 'center',
487491
'decode', 'encode', 'expandtabs', 'join', 'ljust',
488-
'lower', 'lstrip', 'replace', 'rjust', 'rstrip', 'strip',
489-
'swapcase', 'title', 'translate', 'upper', 'zfill']
492+
'lower', 'lstrip', 'replace', 'rjust', 'rstrip',
493+
'strip', 'swapcase', 'title', 'translate', 'upper',
494+
'zfill']
490495
for method in self_methods:
491496
collector(method, self_object)
492497

@@ -514,6 +519,7 @@ def get_object(self):
514519
def get_definition_location(self):
515520
return (None, None)
516521

522+
517523
class Iterator(pyobjects.AbstractClass):
518524

519525
def __init__(self, holding=None):
@@ -539,7 +545,8 @@ def __init__(self, holding=None):
539545
self.holding = holding
540546
self.attributes = {
541547
'next': BuiltinName(BuiltinFunction(self.holding)),
542-
'__iter__': BuiltinName(BuiltinFunction(get_iterator(self.holding))),
548+
'__iter__': BuiltinName(BuiltinFunction(
549+
get_iterator(self.holding))),
543550
'close': BuiltinName(BuiltinFunction()),
544551
'send': BuiltinName(BuiltinFunction()),
545552
'throw': BuiltinName(BuiltinFunction())}
@@ -556,10 +563,10 @@ def get_returned_object(self, args):
556563
class File(BuiltinClass):
557564

558565
def __init__(self):
559-
self_object = pyobjects.PyObject(self)
560566
str_object = get_str()
561567
str_list = get_list(get_str())
562568
attributes = {}
569+
563570
def add(name, returned=None, function=None):
564571
builtin = getattr(file, name, None)
565572
attributes[name] = BuiltinName(
@@ -587,7 +594,8 @@ def __init__(self, fget=None, fset=None, fdel=None, fdoc=None):
587594
'fget': BuiltinName(BuiltinFunction()),
588595
'fset': BuiltinName(pynames.UnboundName()),
589596
'fdel': BuiltinName(pynames.UnboundName()),
590-
'__new__': BuiltinName(BuiltinFunction(function=_property_function))}
597+
'__new__': BuiltinName(
598+
BuiltinFunction(function=_property_function))}
591599
super(Property, self).__init__(property, attributes)
592600

593601
def get_property_object(self, args):
@@ -631,7 +639,7 @@ def get_attributes(self):
631639
return {}
632640

633641
def get_name(self):
634-
return 'lambda'
642+
return 'lambda'
635643

636644
def get_param_names(self, special_args=True):
637645
result = [node.id for node in self.arguments.args
@@ -671,7 +679,7 @@ def _infer_sequence_for_pyname(pyname):
671679
iter = obj.get_returned_object(args)
672680
if iter is not None and 'next' in iter:
673681
holding = iter['next'].get_object().\
674-
get_returned_object(args)
682+
get_returned_object(args)
675683
return holding
676684

677685

@@ -690,12 +698,15 @@ def _create_builtin(args, creator):
690698
def _range_function(args):
691699
return get_list()
692700

701+
693702
def _reversed_function(args):
694703
return _create_builtin(args, get_iterator)
695704

705+
696706
def _sorted_function(args):
697707
return _create_builtin(args, get_list)
698708

709+
699710
def _super_function(args):
700711
passed_class, passed_self = args.get_arguments(['type', 'self'])
701712
if passed_self is None:
@@ -709,6 +720,7 @@ def _super_function(args):
709720
return pyobjects.PyObject(supers[0])
710721
return passed_self
711722

723+
712724
def _zip_function(args):
713725
args = args.get_pynames(['sequence'])
714726
objects = []
@@ -721,6 +733,7 @@ def _zip_function(args):
721733
tuple = get_tuple(*objects)
722734
return get_list(tuple)
723735

736+
724737
def _enumerate_function(args):
725738
passed = args.get_pynames(['sequence'])[0]
726739
if passed is None:
@@ -730,6 +743,7 @@ def _enumerate_function(args):
730743
tuple = get_tuple(None, holding)
731744
return get_iterator(tuple)
732745

746+
733747
def _iter_function(args):
734748
passed = args.get_pynames(['sequence'])[0]
735749
if passed is None:
@@ -738,6 +752,7 @@ def _iter_function(args):
738752
holding = _infer_sequence_for_pyname(passed)
739753
return get_iterator(holding)
740754

755+
741756
def _input_function(args):
742757
return get_str()
743758

@@ -751,17 +766,25 @@ def _input_function(args):
751766
'file': BuiltinName(get_file_type()),
752767
'open': BuiltinName(get_file_type()),
753768
'unicode': BuiltinName(get_str_type()),
754-
'range': BuiltinName(BuiltinFunction(function=_range_function, builtin=range)),
755-
'reversed': BuiltinName(BuiltinFunction(function=_reversed_function, builtin=reversed)),
756-
'sorted': BuiltinName(BuiltinFunction(function=_sorted_function, builtin=sorted)),
757-
'super': BuiltinName(BuiltinFunction(function=_super_function, builtin=super)),
758-
'property': BuiltinName(BuiltinFunction(function=_property_function, builtin=property)),
769+
'range': BuiltinName(BuiltinFunction(function=_range_function,
770+
builtin=range)),
771+
'reversed': BuiltinName(BuiltinFunction(function=_reversed_function,
772+
builtin=reversed)),
773+
'sorted': BuiltinName(BuiltinFunction(function=_sorted_function,
774+
builtin=sorted)),
775+
'super': BuiltinName(BuiltinFunction(function=_super_function,
776+
builtin=super)),
777+
'property': BuiltinName(BuiltinFunction(function=_property_function,
778+
builtin=property)),
759779
'zip': BuiltinName(BuiltinFunction(function=_zip_function, builtin=zip)),
760-
'enumerate': BuiltinName(BuiltinFunction(function=_enumerate_function, builtin=enumerate)),
780+
'enumerate': BuiltinName(BuiltinFunction(function=_enumerate_function,
781+
builtin=enumerate)),
761782
'object': BuiltinName(BuiltinObject()),
762783
'type': BuiltinName(BuiltinType()),
763-
'iter': BuiltinName(BuiltinFunction(function=_iter_function, builtin=iter)),
764-
'raw_input': BuiltinName(BuiltinFunction(function=_input_function, builtin=raw_input)),
765-
}
784+
'iter': BuiltinName(BuiltinFunction(function=_iter_function,
785+
builtin=iter)),
786+
'raw_input': BuiltinName(BuiltinFunction(function=_input_function,
787+
builtin=raw_input)),
788+
}
766789

767790
builtins = BuiltinModule('__builtin__', initial=_initial_builtins)

pymode/libs2/rope/base/change.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import difflib
33
import os
44
import time
5-
import warnings
65

76
import rope.base.fscommands
87
from rope.base import taskhandle, exceptions, utils
@@ -17,13 +16,13 @@ class Change(object):
1716

1817
def do(self, job_set=None):
1918
"""Perform the change
20-
19+
2120
.. note:: Do use this directly. Use `Project.do()` instead.
2221
"""
2322

2423
def undo(self, job_set=None):
2524
"""Perform the change
26-
25+
2726
.. note:: Do use this directly. Use `History.undo()` instead.
2827
"""
2928

@@ -97,7 +96,8 @@ def __str__(self):
9796
date = datetime.datetime.fromtimestamp(self.time)
9897
if date.date() == datetime.date.today():
9998
string_date = 'today'
100-
elif date.date() == (datetime.date.today() - datetime.timedelta(1)):
99+
elif date.date() == (datetime.date.today() -
100+
datetime.timedelta(1)):
101101
string_date = 'yesterday'
102102
elif date.year == datetime.date.today().year:
103103
string_date = date.strftime('%b %d')
@@ -257,7 +257,8 @@ class CreateFolder(CreateResource):
257257
"""
258258

259259
def __init__(self, parent, name):
260-
resource = parent.project.get_folder(self._get_child_path(parent, name))
260+
resource = parent.project.get_folder(
261+
self._get_child_path(parent, name))
261262
super(CreateFolder, self).__init__(resource)
262263

263264

@@ -309,6 +310,7 @@ def count_changes(change):
309310
return result
310311
return 1
311312

313+
312314
def create_job_set(task_handle, change):
313315
return task_handle.create_jobset(str(change), count_changes(change))
314316

pymode/libs2/rope/base/codeanalyze.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def add_change(self, start, end, new_text=None):
1818
def get_changed(self):
1919
if not self.changes:
2020
return None
21+
2122
def compare_changes(change1, change2):
2223
return cmp(change1[:2], change2[:2])
2324
self.changes.sort(compare_changes)
@@ -131,6 +132,7 @@ def __call__(self):
131132
return result
132133

133134
_main_chars = re.compile(r'[\'|"|#|\\|\[|\]|\{|\}|\(|\)]')
135+
134136
def _analyze_line(self, line):
135137
char = None
136138
for match in self._main_chars.finditer(line):
@@ -142,8 +144,8 @@ def _analyze_line(self, line):
142144
if char * 3 == line[i:i + 3]:
143145
self.in_string = char * 3
144146
elif self.in_string == line[i:i + len(self.in_string)] and \
145-
not (i > 0 and line[i - 1] == '\\' and
146-
not (i > 1 and line[i - 2] == '\\')):
147+
not (i > 0 and line[i - 1] == '\\' and
148+
not (i > 1 and line[i - 2] == '\\')):
147149
self.in_string = ''
148150
if self.in_string:
149151
continue
@@ -158,6 +160,7 @@ def _analyze_line(self, line):
158160
else:
159161
self.continuation = False
160162

163+
161164
def custom_generator(lines):
162165
return _CustomGenerator(lines)()
163166

@@ -189,7 +192,6 @@ def generate_regions(self, start_line=1, end_line=None):
189192
# XXX: `block_start` should be at a better position!
190193
block_start = 1
191194
readline = LinesToReadline(self.lines, block_start)
192-
shifted = start_line - block_start + 1
193195
try:
194196
for start, end in self._logical_lines(readline):
195197
real_start = start + block_start - 1
@@ -199,7 +201,7 @@ def generate_regions(self, start_line=1, end_line=None):
199201
real_end = end + block_start - 1
200202
if real_start >= start_line:
201203
yield (real_start, real_end)
202-
except tokenize.TokenError, e:
204+
except tokenize.TokenError:
203205
pass
204206

205207
def _block_logical_line(self, block_start, line_number):
@@ -254,13 +256,15 @@ def __init__(self, lines, generate=custom_generator):
254256
self._generate = generate
255257

256258
_starts = None
259+
257260
@property
258261
def starts(self):
259262
if self._starts is None:
260263
self._init_logicals()
261264
return self._starts
262265

263266
_ends = None
267+
264268
@property
265269
def ends(self):
266270
if self._ends is None:
@@ -326,6 +330,7 @@ def get_block_start(lines, lineno, maximum_indents=80):
326330

327331
_block_start_pattern = None
328332

333+
329334
def get_block_start_patterns():
330335
global _block_start_pattern
331336
if not _block_start_pattern:
@@ -350,9 +355,10 @@ def count_line_indents(line):
350355
def get_string_pattern():
351356
start = r'(\b[uU]?[rR]?)?'
352357
longstr = r'%s"""(\\.|"(?!"")|\\\n|[^"\\])*"""' % start
353-
shortstr = r'%s"(\\.|[^"\\\n])*"' % start
358+
shortstr = r'%s"(\\.|\\\n|[^"\\])*"' % start
354359
return '|'.join([longstr, longstr.replace('"', "'"),
355360
shortstr, shortstr.replace('"', "'")])
356361

362+
357363
def get_comment_pattern():
358364
return r'#[^\n]*'

0 commit comments

Comments
 (0)