88using System . Numerics ;
99using System . Runtime . InteropServices ;
1010
11- using Microsoft . Scripting ;
12- using Microsoft . Scripting . Runtime ;
13- using Microsoft . Scripting . Utils ;
14-
1511using IronPython . Runtime ;
1612using IronPython . Runtime . Binding ;
1713using IronPython . Runtime . Exceptions ;
1814using IronPython . Runtime . Operations ;
1915using IronPython . Runtime . Types ;
2016
17+ using Microsoft . Scripting ;
18+ using Microsoft . Scripting . Runtime ;
19+ using Microsoft . Scripting . Utils ;
20+
2121[ assembly: PythonModule ( "itertools" , typeof ( IronPython . Modules . PythonIterTools ) ) ]
2222namespace IronPython . Modules {
2323 public static class PythonIterTools {
@@ -219,7 +219,7 @@ private static void EnsureIterator(CodeContext/*!*/ context, object iter) {
219219 if ( iter == null ||
220220 ! PythonOps . HasAttr ( context , iter , "__iter__" ) &&
221221 ! PythonOps . HasAttr ( context , iter , "__getitem__" ) ) {
222- throw PythonOps . TypeError ( "'{0}' object is not iterable" , PythonOps . GetPythonTypeName ( iter ) ) ;
222+ throw PythonOps . TypeError ( "'{0}' object is not iterable" , PythonOps . GetPythonTypeName ( iter ) ) ;
223223 }
224224 }
225225
@@ -262,13 +262,13 @@ public count(BigInteger start) {
262262 InnerEnumerator = BigIntYielder ( this , start , 1 ) ;
263263 }
264264
265- public count ( int start = 0 , int step = 1 ) {
265+ public count ( int start = 0 , int step = 1 ) {
266266 _curInt = start ;
267267 _step = step ;
268268 InnerEnumerator = IntYielder ( this , start , step ) ;
269269 }
270270
271- public count ( [ DefaultParameterValue ( 0 ) ] int start , BigInteger step ) {
271+ public count ( [ DefaultParameterValue ( 0 ) ] int start , BigInteger step ) {
272272 _curInt = start ;
273273 _step = step ;
274274 InnerEnumerator = IntYielder ( this , start , step ) ;
@@ -286,7 +286,7 @@ public count(BigInteger start, BigInteger step) {
286286 InnerEnumerator = BigIntYielder ( this , start , step ) ;
287287 }
288288
289- public count ( CodeContext /*!*/ context , [ DefaultParameterValue ( 0 ) ] object start , [ DefaultParameterValue ( 1 ) ] object step ) {
289+ public count ( CodeContext /*!*/ context , [ DefaultParameterValue ( 0 ) ] object start , [ DefaultParameterValue ( 1 ) ] object step ) {
290290 EnsureNumeric ( context , start ) ;
291291 EnsureNumeric ( context , step ) ;
292292 _cur = start ;
@@ -301,7 +301,7 @@ private static void EnsureNumeric(CodeContext/*!*/ context, object num) {
301301 if ( num == null ||
302302 ! PythonOps . HasAttr ( context , num , "__int__" ) &&
303303 ! PythonOps . HasAttr ( context , num , "__float__" ) ) {
304- throw PythonOps . TypeError ( "a number is required" ) ;
304+ throw PythonOps . TypeError ( "a number is required" ) ;
305305 }
306306 }
307307
@@ -517,9 +517,9 @@ private IEnumerator<object> Yielder(IEnumerator iter) {
517517 if ( MoveNextHelper ( iter ) ) {
518518 while ( ! _fFinished ) {
519519 while ( PythonContext . Equal ( GetKey ( iter . Current ) , curKey ) ) {
520- if ( ! MoveNextHelper ( iter ) ) {
521- _fFinished = true ;
522- yield break ;
520+ if ( ! MoveNextHelper ( iter ) ) {
521+ _fFinished = true ;
522+ yield break ;
523523 }
524524 }
525525 curKey = GetKey ( iter . Current ) ;
@@ -531,9 +531,9 @@ private IEnumerator<object> Yielder(IEnumerator iter) {
531531 private IEnumerator < object > Grouper ( IEnumerator iter , object curKey ) {
532532 while ( PythonContext . Equal ( GetKey ( iter . Current ) , curKey ) ) {
533533 yield return iter . Current ;
534- if ( ! MoveNextHelper ( iter ) ) {
535- _fFinished = true ;
536- yield break ;
534+ if ( ! MoveNextHelper ( iter ) ) {
535+ _fFinished = true ;
536+ yield break ;
537537 }
538538 }
539539 }
@@ -658,7 +658,7 @@ public zip_longest(params object[] iterables) {
658658 }
659659 }
660660
661- public zip_longest ( [ ParamDictionary ] IDictionary < object , object > paramDict , params object [ ] iterables ) {
661+ public zip_longest ( [ ParamDictionary ] IDictionary < object , object > paramDict , params object [ ] iterables ) {
662662 object fill ;
663663
664664 if ( paramDict . TryGetValue ( "fillvalue" , out fill ) ) {
@@ -747,7 +747,7 @@ public product(CodeContext context, params object[] iterables) {
747747 InnerEnumerator = Yielder ( ArrayUtils . ConvertAll ( iterables , x => new PythonList ( context , PythonOps . GetEnumerator ( x ) ) ) ) ;
748748 }
749749
750- public product ( CodeContext context , [ ParamDictionary ] IDictionary < object , object > paramDict , params object [ ] iterables ) {
750+ public product ( CodeContext context , [ ParamDictionary ] IDictionary < object , object > paramDict , params object [ ] iterables ) {
751751 object repeat ;
752752 int iRepeat = 1 ;
753753 if ( paramDict . TryGetValue ( "repeat" , out repeat ) ) {
@@ -970,7 +970,7 @@ public permutations(CodeContext context, object iterable) {
970970
971971 public permutations ( CodeContext context , object iterable , object r ) {
972972 _data = new PythonList ( context , iterable ) ;
973-
973+
974974 InnerEnumerator = Yielder ( GetR ( r , _data ) ) ;
975975 }
976976
@@ -1133,9 +1133,9 @@ IEnumerator IEnumerable.GetEnumerator() {
11331133
11341134 #endregion
11351135 }
1136-
1136+
11371137 [ PythonType ]
1138- public class starmap : IterBase {
1138+ public class starmap : IterBase {
11391139 public starmap ( CodeContext context , object function , object iterable ) {
11401140 InnerEnumerator = Yielder ( context , function , PythonOps . GetEnumerator ( iterable ) ) ;
11411141 }
@@ -1194,7 +1194,7 @@ public void __setstate__(object state) {
11941194
11951195 private IEnumerator < object > Yielder ( object predicate , IEnumerator iter ) {
11961196 while ( MoveNextHelper ( iter ) ) {
1197- if ( ! Converter . ConvertToBoolean (
1197+ if ( ! Converter . ConvertToBoolean (
11981198 _context . LanguageContext . CallSplat ( predicate , iter . Current )
11991199 ) ) {
12001200 break ;
0 commit comments