-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython.py
1479 lines (1250 loc) · 50.3 KB
/
python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import _hx_AnonObject as anon
from _hx_AnonObject import _hx_AnonObject
import globalClasses
from classes_hscript import Enum, HxOverrides, HxString, Std
import math as Math
import inspect as python_lib_Inspect
import sys as python_lib_Sys
import math as Math
import functools as python_lib_Functools
from haxe import haxe_io_Input, haxe_io_Output
class python_Boot:
_hx_class_name = "python.Boot"
__slots__ = ()
_hx_statics = ["keywords", "arrayJoin", "safeJoin", "isPyBool", "isPyInt", "isPyFloat", "isClass", "isAnonObject", "_add_dynamic", "toString", "toString1", "isMetaType", "fields", "isString", "isArray", "simpleField", "createClosure", "hasField", "field", "getInstanceFields", "getSuperClass", "getClassFields", "unsafeFastCodeAt", "handleKeywords", "prefixLength", "unhandleKeywords", "implementsInterface"]
@staticmethod
def arrayJoin(x,sep):
return sep.join([python_Boot.toString1(x1,'') for x1 in x])
@staticmethod
def safeJoin(x,sep):
return sep.join([x1 for x1 in x])
@staticmethod
def isPyBool(o):
return isinstance(o,bool)
@staticmethod
def isPyInt(o):
if isinstance(o,int):
return (not isinstance(o,bool))
else:
return False
@staticmethod
def isPyFloat(o):
return isinstance(o,float)
@staticmethod
def isClass(o):
if (o is not None):
if not HxOverrides.eq(o,str):
return python_lib_Inspect.isclass(o)
else:
return True
else:
return False
@staticmethod
def isAnonObject(o):
return isinstance(o,_hx_AnonObject)
@staticmethod
def _add_dynamic(a,b):
if (isinstance(a,str) and isinstance(b,str)):
return (a + b)
if (isinstance(a,str) or isinstance(b,str)):
return (python_Boot.toString1(a,"") + python_Boot.toString1(b,""))
return (a + b)
@staticmethod
def toString(o):
return python_Boot.toString1(o,"")
@staticmethod
def toString1(o,s):
if (o is None):
return "null"
if isinstance(o,str):
return o
if (s is None):
s = ""
if (len(s) >= 5):
return "<...>"
if isinstance(o,bool):
if o:
return "true"
else:
return "false"
if (isinstance(o,int) and (not isinstance(o,bool))):
return str(o)
if isinstance(o,float):
try:
if (o == int(o)):
return str(Math.floor((o + 0.5)))
else:
return str(o)
except BaseException as _g:
None
return str(o)
if isinstance(o,list):
o1 = o
l = len(o1)
st = "["
s = (("null" if s is None else s) + "\t")
_g = 0
_g1 = l
while (_g < _g1):
i = _g
_g = (_g + 1)
prefix = ""
if (i > 0):
prefix = ","
st = (("null" if st is None else st) + HxOverrides.stringOrNull(((("null" if prefix is None else prefix) + HxOverrides.stringOrNull(python_Boot.toString1((o1[i] if i >= 0 and i < len(o1) else None),s))))))
st = (("null" if st is None else st) + "]")
return st
try:
if hasattr(o,"toString"):
return o.toString()
except BaseException as _g:
None
if hasattr(o,"__class__"):
if isinstance(o,_hx_AnonObject):
toStr = None
try:
fields = python_Boot.fields(o)
_g = []
_g1 = 0
while (_g1 < len(fields)):
f = (fields[_g1] if _g1 >= 0 and _g1 < len(fields) else None)
_g1 = (_g1 + 1)
x = ((("" + ("null" if f is None else f)) + " : ") + HxOverrides.stringOrNull(python_Boot.toString1(python_Boot.simpleField(o,f),(("null" if s is None else s) + "\t"))))
_g.append(x)
fieldsStr = _g
toStr = (("{ " + HxOverrides.stringOrNull(", ".join([x1 for x1 in fieldsStr]))) + " }")
except BaseException as _g:
None
return "{ ... }"
if (toStr is None):
return "{ ... }"
else:
return toStr
if isinstance(o,Enum):
o1 = o
l = len(o1.params)
hasParams = (l > 0)
if hasParams:
paramsStr = ""
_g = 0
_g1 = l
while (_g < _g1):
i = _g
_g = (_g + 1)
prefix = ""
if (i > 0):
prefix = ","
paramsStr = (("null" if paramsStr is None else paramsStr) + HxOverrides.stringOrNull(((("null" if prefix is None else prefix) + HxOverrides.stringOrNull(python_Boot.toString1(o1.params[i],s))))))
return (((HxOverrides.stringOrNull(o1.tag) + "(") + ("null" if paramsStr is None else paramsStr)) + ")")
else:
return o1.tag
if hasattr(o,"_hx_class_name"):
if (o.__class__.__name__ != "type"):
fields = python_Boot.getInstanceFields(o)
_g = []
_g1 = 0
while (_g1 < len(fields)):
f = (fields[_g1] if _g1 >= 0 and _g1 < len(fields) else None)
_g1 = (_g1 + 1)
x = ((("" + ("null" if f is None else f)) + " : ") + HxOverrides.stringOrNull(python_Boot.toString1(python_Boot.simpleField(o,f),(("null" if s is None else s) + "\t"))))
_g.append(x)
fieldsStr = _g
toStr = (((HxOverrides.stringOrNull(o._hx_class_name) + "( ") + HxOverrides.stringOrNull(", ".join([x1 for x1 in fieldsStr]))) + " )")
return toStr
else:
fields = python_Boot.getClassFields(o)
_g = []
_g1 = 0
while (_g1 < len(fields)):
f = (fields[_g1] if _g1 >= 0 and _g1 < len(fields) else None)
_g1 = (_g1 + 1)
x = ((("" + ("null" if f is None else f)) + " : ") + HxOverrides.stringOrNull(python_Boot.toString1(python_Boot.simpleField(o,f),(("null" if s is None else s) + "\t"))))
_g.append(x)
fieldsStr = _g
toStr = (((("#" + HxOverrides.stringOrNull(o._hx_class_name)) + "( ") + HxOverrides.stringOrNull(", ".join([x1 for x1 in fieldsStr]))) + " )")
return toStr
if ((type(o) == type) and (o == str)):
return "#String"
if ((type(o) == type) and (o == list)):
return "#Array"
if callable(o):
return "function"
try:
if hasattr(o,"__repr__"):
return o.__repr__()
except BaseException as _g:
None
if hasattr(o,"__str__"):
return o.__str__([])
if hasattr(o,"__name__"):
return o.__name__
return "???"
else:
return str(o)
@staticmethod
def isMetaType(v,t):
return ((type(v) == type) and (v == t))
@staticmethod
def fields(o):
a = []
if (o is not None):
if hasattr(o,"_hx_fields"):
fields = o._hx_fields
if (fields is not None):
return list(fields)
if isinstance(o,_hx_AnonObject):
d = o.__dict__
keys = d.keys()
handler = python_Boot.unhandleKeywords
for k in keys:
if (k != '_hx_disable_getattr'):
a.append(handler(k))
elif hasattr(o,"__dict__"):
d = o.__dict__
keys1 = d.keys()
for k in keys1:
a.append(k)
return a
@staticmethod
def isString(o):
return isinstance(o,str)
@staticmethod
def isArray(o):
return isinstance(o,list)
@staticmethod
def simpleField(o,field):
if (field is None):
return None
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
@staticmethod
def createClosure(obj,func):
return python_internal_MethodClosure(obj,func)
@staticmethod
def hasField(o,field):
if isinstance(o,_hx_AnonObject):
return o._hx_hasattr(field)
return hasattr(o,(("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field)))
@staticmethod
def field(o,field):
if (field is None):
return None
if isinstance(o,str):
field1 = field
_hx_local_0 = len(field1)
if (_hx_local_0 == 10):
if (field1 == "charCodeAt"):
return python_internal_MethodClosure(o,HxString.charCodeAt)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 11):
if (field1 == "lastIndexOf"):
return python_internal_MethodClosure(o,HxString.lastIndexOf)
elif (field1 == "toLowerCase"):
return python_internal_MethodClosure(o,HxString.toLowerCase)
elif (field1 == "toUpperCase"):
return python_internal_MethodClosure(o,HxString.toUpperCase)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 9):
if (field1 == "substring"):
return python_internal_MethodClosure(o,HxString.substring)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 5):
if (field1 == "split"):
return python_internal_MethodClosure(o,HxString.split)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 7):
if (field1 == "indexOf"):
return python_internal_MethodClosure(o,HxString.indexOf)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 8):
if (field1 == "toString"):
return python_internal_MethodClosure(o,HxString.toString)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_0 == 6):
if (field1 == "charAt"):
return python_internal_MethodClosure(o,HxString.charAt)
elif (field1 == "length"):
return len(o)
elif (field1 == "substr"):
return python_internal_MethodClosure(o,HxString.substr)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif isinstance(o,list):
field1 = field
_hx_local_1 = len(field1)
if (_hx_local_1 == 11):
if (field1 == "lastIndexOf"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.lastIndexOf)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 4):
if (field1 == "copy"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.copy)
elif (field1 == "join"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.join)
elif (field1 == "push"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.push)
elif (field1 == "sort"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.sort)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 5):
if (field1 == "shift"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.shift)
elif (field1 == "slice"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.slice)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 7):
if (field1 == "indexOf"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.indexOf)
elif (field1 == "reverse"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.reverse)
elif (field1 == "unshift"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.unshift)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 3):
if (field1 == "map"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.map)
elif (field1 == "pop"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.pop)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 8):
if (field1 == "contains"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.contains)
elif (field1 == "iterator"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.iterator)
elif (field1 == "toString"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.toString)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 16):
if (field1 == "keyValueIterator"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.keyValueIterator)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
elif (_hx_local_1 == 6):
if (field1 == "concat"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.concat)
elif (field1 == "filter"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.filter)
elif (field1 == "insert"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.insert)
elif (field1 == "length"):
return len(o)
elif (field1 == "remove"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.remove)
elif (field1 == "splice"):
return python_internal_MethodClosure(o,python_internal_ArrayImpl.splice)
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
else:
field1 = (("_hx_" + field) if ((field in python_Boot.keywords)) else (("_hx_" + field) if (((((len(field) > 2) and ((ord(field[0]) == 95))) and ((ord(field[1]) == 95))) and ((ord(field[(len(field) - 1)]) != 95)))) else field))
if hasattr(o,field1):
return getattr(o,field1)
else:
return None
@staticmethod
def getInstanceFields(c):
f = (list(c._hx_fields) if (hasattr(c,"_hx_fields")) else [])
if hasattr(c,"_hx_methods"):
f = (f + c._hx_methods)
sc = python_Boot.getSuperClass(c)
if (sc is None):
return f
else:
scArr = python_Boot.getInstanceFields(sc)
scMap = set(scArr)
_g = 0
while (_g < len(f)):
f1 = (f[_g] if _g >= 0 and _g < len(f) else None)
_g = (_g + 1)
if (not (f1 in scMap)):
scArr.append(f1)
return scArr
@staticmethod
def getSuperClass(c):
if (c is None):
return None
try:
if hasattr(c,"_hx_super"):
return c._hx_super
return None
except BaseException as _g:
None
return None
@staticmethod
def getClassFields(c):
if hasattr(c,"_hx_statics"):
x = c._hx_statics
return list(x)
else:
return []
@staticmethod
def unsafeFastCodeAt(s,index):
return ord(s[index])
@staticmethod
def handleKeywords(name):
if (name in python_Boot.keywords):
return ("_hx_" + name)
elif ((((len(name) > 2) and ((ord(name[0]) == 95))) and ((ord(name[1]) == 95))) and ((ord(name[(len(name) - 1)]) != 95))):
return ("_hx_" + name)
else:
return name
@staticmethod
def unhandleKeywords(name):
if (HxString.substr(name,0,python_Boot.prefixLength) == "_hx_"):
real = HxString.substr(name,python_Boot.prefixLength,None)
if (real in python_Boot.keywords):
return real
return name
@staticmethod
def implementsInterface(value,cls):
loop = None
def _hx_local_1(intf):
f = (intf._hx_interfaces if (hasattr(intf,"_hx_interfaces")) else [])
if (f is not None):
_g = 0
while (_g < len(f)):
i = (f[_g] if _g >= 0 and _g < len(f) else None)
_g = (_g + 1)
if (i == cls):
return True
else:
l = loop(i)
if l:
return True
return False
else:
return False
loop = _hx_local_1
currentClass = value.__class__
result = False
while (currentClass is not None):
if loop(currentClass):
result = True
break
currentClass = python_Boot.getSuperClass(currentClass)
return result
python_Boot._hx_class = python_Boot
globalClasses._hx_classes["python.Boot"] = python_Boot
class python_HaxeIterable:
_hx_class_name = "python.HaxeIterable"
__slots__ = ("x",)
_hx_fields = ["x"]
_hx_methods = ["iterator"]
def __init__(self,x):
self.x = x
def iterator(self):
return python_HaxeIterator(self.x.__iter__())
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.x = None
python_HaxeIterable._hx_class = python_HaxeIterable
globalClasses._hx_classes["python.HaxeIterable"] = python_HaxeIterable
class python_HaxeIterator:
_hx_class_name = "python.HaxeIterator"
__slots__ = ("it", "x", "has", "checked")
_hx_fields = ["it", "x", "has", "checked"]
_hx_methods = ["next", "hasNext"]
def __init__(self,it):
self.checked = False
self.has = False
self.x = None
self.it = it
def next(self):
if (not self.checked):
self.hasNext()
self.checked = False
return self.x
def hasNext(self):
from haxe import haxe_Exception
if (not self.checked):
try:
self.x = self.it.__next__()
self.has = True
except BaseException as _g:
None
if Std.isOfType(haxe_Exception.caught(_g).unwrap(),StopIteration):
self.has = False
self.x = None
else:
raise _g
self.checked = True
return self.has
@staticmethod
def _hx_empty_init(_hx_o):
_hx_o.it = None
_hx_o.x = None
_hx_o.has = None
_hx_o.checked = None
python_HaxeIterator._hx_class = python_HaxeIterator
globalClasses._hx_classes["python.HaxeIterator"] = python_HaxeIterator
class python_Lib:
_hx_class_name = "python.Lib"
__slots__ = ()
_hx_statics = ["lineEnd", "get___name__", "print", "printString", "println", "dictToAnon", "anonToDict", "anonAsDict", "dictAsAnon", "toPythonIterable", "toHaxeIterable", "toHaxeIterator"]
__name__ = None
@staticmethod
def get___name__():
return __name__
@staticmethod
def print(v):
python_Lib.printString(Std.string(v))
@staticmethod
def printString(_hx_str):
encoding = "utf-8"
if (encoding is None):
encoding = "utf-8"
python_lib_Sys.stdout.buffer.write(_hx_str.encode(encoding, "strict"))
python_lib_Sys.stdout.flush()
@staticmethod
def println(v):
_hx_str = Std.string(v)
python_Lib.printString((("" + ("null" if _hx_str is None else _hx_str)) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
@staticmethod
def dictToAnon(v):
return _hx_AnonObject(v.copy())
@staticmethod
def anonToDict(o):
if isinstance(o,_hx_AnonObject):
return o.__dict__.copy()
else:
return None
@staticmethod
def anonAsDict(o):
if isinstance(o,_hx_AnonObject):
return o.__dict__
else:
return None
@staticmethod
def dictAsAnon(d):
return _hx_AnonObject(d)
@staticmethod
def toPythonIterable(it):
def _hx_local_3():
def _hx_local_2():
from haxe import haxe_Exception
it1 = HxOverrides.iterator(it)
_hx_self = None
def _hx_local_0():
if it1.hasNext():
return it1.next()
else:
raise haxe_Exception.thrown(StopIteration())
def _hx_local_1():
return _hx_self
this1 = _hx_AnonObject({'__next__': _hx_local_0, '__iter__': _hx_local_1})
_hx_self = this1
return _hx_self
return _hx_AnonObject({'__iter__': _hx_local_2})
return _hx_local_3()
@staticmethod
def toHaxeIterable(it):
return python_HaxeIterable(it)
@staticmethod
def toHaxeIterator(it):
return python_HaxeIterator(it)
python_Lib._hx_class = python_Lib
globalClasses._hx_classes["python.Lib"] = python_Lib
class python_NativeStringTools:
_hx_class_name = "python.NativeStringTools"
__slots__ = ()
_hx_statics = ["format", "encode", "contains", "strip", "rpartition", "startswith", "endswith"]
@staticmethod
def format(s,args):
return s.format(*args)
@staticmethod
def encode(s,encoding = None,errors = None):
if (encoding is None):
encoding = "utf-8"
if (errors is None):
errors = "strict"
return s.encode(encoding, errors)
@staticmethod
def contains(s,e):
return (e in s)
@staticmethod
def strip(s,chars = None):
return s.strip(chars)
@staticmethod
def rpartition(s,sep):
return s.rpartition(sep)
@staticmethod
def startswith(s,prefix):
return s.startswith(prefix)
@staticmethod
def endswith(s,suffix):
return s.endswith(suffix)
python_NativeStringTools._hx_class = python_NativeStringTools
globalClasses._hx_classes["python.NativeStringTools"] = python_NativeStringTools
class python__KwArgs_KwArgs_Impl_:
_hx_class_name = "python._KwArgs.KwArgs_Impl_"
__slots__ = ()
_hx_statics = ["_new", "toDict", "toDictHelper", "fromDict", "fromT", "typed", "get"]
@staticmethod
def _new(d):
this1 = d
return this1
@staticmethod
def toDict(this1):
return python__KwArgs_KwArgs_Impl_.toDictHelper(this1,None)
@staticmethod
def toDictHelper(this1,x):
return this1
@staticmethod
def fromDict(d):
this1 = d
return this1
@staticmethod
def fromT(d):
this1 = python_Lib.anonAsDict(d)
return this1
@staticmethod
def typed(this1):
return _hx_AnonObject(python__KwArgs_KwArgs_Impl_.toDictHelper(this1,None))
@staticmethod
def get(this1,key,_hx_def):
return this1.get(key,_hx_def)
python__KwArgs_KwArgs_Impl_._hx_class = python__KwArgs_KwArgs_Impl_
globalClasses._hx_classes["python._KwArgs.KwArgs_Impl_"] = python__KwArgs_KwArgs_Impl_
class python__NativeIterable_NativeIterable_Impl_:
_hx_class_name = "python._NativeIterable.NativeIterable_Impl_"
__slots__ = ()
_hx_statics = ["toHaxeIterable", "iterator"]
@staticmethod
def toHaxeIterable(this1):
return python_HaxeIterable(this1)
@staticmethod
def iterator(this1):
return python_HaxeIterator(this1.__iter__())
python__NativeIterable_NativeIterable_Impl_._hx_class = python__NativeIterable_NativeIterable_Impl_
globalClasses._hx_classes["python._NativeIterable.NativeIterable_Impl_"] = python__NativeIterable_NativeIterable_Impl_
class python__NativeIterator_NativeIterator_Impl_:
_hx_class_name = "python._NativeIterator.NativeIterator_Impl_"
__slots__ = ()
_hx_statics = ["_new", "toHaxeIterator"]
@staticmethod
def _new(p):
this1 = p
return this1
@staticmethod
def toHaxeIterator(this1):
return python_HaxeIterator(this1)
python__NativeIterator_NativeIterator_Impl_._hx_class = python__NativeIterator_NativeIterator_Impl_
globalClasses._hx_classes["python._NativeIterator.NativeIterator_Impl_"] = python__NativeIterator_NativeIterator_Impl_
class python__VarArgs_VarArgs_Impl_:
_hx_class_name = "python._VarArgs.VarArgs_Impl_"
__slots__ = ()
_hx_statics = ["_new", "raw", "toArray", "fromArray"]
@staticmethod
def _new(d):
this1 = d
return this1
@staticmethod
def raw(this1):
return this1
@staticmethod
def toArray(this1):
if (not Std.isOfType(this1,list)):
return list(this1)
else:
return this1
@staticmethod
def fromArray(d):
this1 = d
return this1
python__VarArgs_VarArgs_Impl_._hx_class = python__VarArgs_VarArgs_Impl_
globalClasses._hx_classes["python._VarArgs.VarArgs_Impl_"] = python__VarArgs_VarArgs_Impl_
class python_internal_ArrayImpl:
_hx_class_name = "python.internal.ArrayImpl"
__slots__ = ()
_hx_statics = ["get_length", "concat", "copy", "iterator", "keyValueIterator", "indexOf", "lastIndexOf", "join", "toString", "pop", "push", "unshift", "remove", "contains", "shift", "slice", "sort", "splice", "map", "filter", "insert", "reverse", "_get", "_set", "unsafeGet", "unsafeSet", "resize"]
@staticmethod
def get_length(x):
return len(x)
@staticmethod
def concat(a1,a2):
return (a1 + a2)
@staticmethod
def copy(x):
return list(x)
@staticmethod
def iterator(x):
return python_HaxeIterator(x.__iter__())
@staticmethod
def keyValueIterator(x):
from haxe import haxe_iterators_ArrayKeyValueIterator
return haxe_iterators_ArrayKeyValueIterator(x)
@staticmethod
def indexOf(a,x,fromIndex = None):
_hx_len = len(a)
l = (0 if ((fromIndex is None)) else ((_hx_len + fromIndex) if ((fromIndex < 0)) else fromIndex))
if (l < 0):
l = 0
_g = l
_g1 = _hx_len
while (_g < _g1):
i = _g
_g = (_g + 1)
if HxOverrides.eq(a[i],x):
return i
return -1
@staticmethod
def lastIndexOf(a,x,fromIndex = None):
_hx_len = len(a)
l = (_hx_len if ((fromIndex is None)) else (((_hx_len + fromIndex) + 1) if ((fromIndex < 0)) else (fromIndex + 1)))
if (l > _hx_len):
l = _hx_len
while True:
l = (l - 1)
tmp = l
if (not ((tmp > -1))):
break
if HxOverrides.eq(a[l],x):
return l
return -1
@staticmethod
def join(x,sep):
return sep.join([python_Boot.toString1(x1,'') for x1 in x])
@staticmethod
def toString(x):
return (("[" + HxOverrides.stringOrNull(",".join([python_Boot.toString1(x1,'') for x1 in x]))) + "]")
@staticmethod
def pop(x):
if (len(x) == 0):
return None
else:
return x.pop()
@staticmethod
def push(x,e):
x.append(e)
return len(x)
@staticmethod
def unshift(x,e):
x.insert(0, e)
@staticmethod
def remove(x,e):
try:
x.remove(e)
return True
except BaseException as _g:
None
return False
@staticmethod
def contains(x,e):
return (e in x)
@staticmethod
def shift(x):
if (len(x) == 0):
return None
return x.pop(0)
@staticmethod
def slice(x,pos,end = None):
return x[pos:end]
@staticmethod
def sort(x,f):
x.sort(key= python_lib_Functools.cmp_to_key(f))
@staticmethod
def splice(x,pos,_hx_len):
if (pos < 0):
pos = (len(x) + pos)
if (pos < 0):
pos = 0
res = x[pos:(pos + _hx_len)]
del x[pos:(pos + _hx_len)]
return res
@staticmethod
def map(x,f):
return list(map(f,x))
@staticmethod
def filter(x,f):
return list(filter(f,x))
@staticmethod
def insert(a,pos,x):
a.insert(pos, x)
@staticmethod
def reverse(a):
a.reverse()
@staticmethod
def _get(x,idx):
if ((idx > -1) and ((idx < len(x)))):
return x[idx]
else:
return None
@staticmethod
def _set(x,idx,v):
l = len(x)
while (l < idx):
x.append(None)
l = (l + 1)
if (l == idx):
x.append(v)
else:
x[idx] = v
return v
@staticmethod
def unsafeGet(x,idx):
return x[idx]
@staticmethod
def unsafeSet(x,idx,val):
x[idx] = val
return val
@staticmethod
def resize(x,_hx_len):
l = len(x)
if (l < _hx_len):
idx = (_hx_len - 1)
v = None
l1 = len(x)
while (l1 < idx):
x.append(None)