@@ -149,8 +149,10 @@ def _get_builtin(*args):
149149 return cls ._generated [args ]
150150 return _get_builtin
151151
152+
152153def _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+
517523class 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):
556563class 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):
690698def _range_function (args ):
691699 return get_list ()
692700
701+
693702def _reversed_function (args ):
694703 return _create_builtin (args , get_iterator )
695704
705+
696706def _sorted_function (args ):
697707 return _create_builtin (args , get_list )
698708
709+
699710def _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+
712724def _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+
724737def _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+
733747def _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+
741756def _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
767790builtins = BuiltinModule ('__builtin__' , initial = _initial_builtins )
0 commit comments