xrfragment/dist/xrfragment.py

1385 lines
53 KiB
Python
Raw Normal View History

2023-03-09 19:58:08 +01:00
import sys
import math as python_lib_Math
import math as Math
import inspect as python_lib_Inspect
import sys as python_lib_Sys
import functools as python_lib_Functools
import re as python_lib_Re
import traceback as python_lib_Traceback
class _hx_AnonObject:
_hx_disable_getattr = False
def __init__(self, fields):
self.__dict__ = fields
def __repr__(self):
return repr(self.__dict__)
def __contains__(self, item):
return item in self.__dict__
def __getitem__(self, item):
return self.__dict__[item]
def __getattr__(self, name):
if (self._hx_disable_getattr):
raise AttributeError('field does not exist')
else:
return None
def _hx_hasattr(self,field):
self._hx_disable_getattr = True
try:
getattr(self, field)
self._hx_disable_getattr = False
return True
except AttributeError:
self._hx_disable_getattr = False
return False
class Enum:
_hx_class_name = "Enum"
__slots__ = ("tag", "index", "params")
_hx_fields = ["tag", "index", "params"]
_hx_methods = ["__str__"]
def __init__(self,tag,index,params):
self.tag = tag
self.index = index
self.params = params
def __str__(self):
if (self.params is None):
return self.tag
else:
return self.tag + '(' + (', '.join(str(v) for v in self.params)) + ')'
class Class: pass
class EReg:
_hx_class_name = "EReg"
__slots__ = ("pattern", "matchObj", "_hx_global")
_hx_fields = ["pattern", "matchObj", "global"]
def __init__(self,r,opt):
self.matchObj = None
self._hx_global = False
options = 0
_g = 0
_g1 = len(opt)
while (_g < _g1):
i = _g
_g = (_g + 1)
c = (-1 if ((i >= len(opt))) else ord(opt[i]))
if (c == 109):
options = (options | python_lib_Re.M)
if (c == 105):
options = (options | python_lib_Re.I)
if (c == 115):
options = (options | python_lib_Re.S)
if (c == 117):
options = (options | python_lib_Re.U)
if (c == 103):
self._hx_global = True
self.pattern = python_lib_Re.compile(r,options)
class Reflect:
_hx_class_name = "Reflect"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_hx_statics = ["field"]
2023-03-09 19:58:08 +01:00
@staticmethod
def field(o,field):
return python_Boot.field(o,field)
class Std:
_hx_class_name = "Std"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_hx_statics = ["isOfType", "string", "parseInt"]
2023-03-09 19:58:08 +01:00
@staticmethod
def isOfType(v,t):
if ((v is None) and ((t is None))):
return False
if (t is None):
return False
if ((type(t) == type) and (t == Dynamic)):
return (v is not None)
isBool = isinstance(v,bool)
if (((type(t) == type) and (t == Bool)) and isBool):
return True
if ((((not isBool) and (not ((type(t) == type) and (t == Bool)))) and ((type(t) == type) and (t == Int))) and isinstance(v,int)):
return True
vIsFloat = isinstance(v,float)
tmp = None
tmp1 = None
if (((not isBool) and vIsFloat) and ((type(t) == type) and (t == Int))):
f = v
tmp1 = (((f != Math.POSITIVE_INFINITY) and ((f != Math.NEGATIVE_INFINITY))) and (not python_lib_Math.isnan(f)))
else:
tmp1 = False
if tmp1:
tmp1 = None
try:
tmp1 = int(v)
except BaseException as _g:
None
tmp1 = None
tmp = (v == tmp1)
else:
tmp = False
if ((tmp and ((v <= 2147483647))) and ((v >= -2147483648))):
return True
if (((not isBool) and ((type(t) == type) and (t == Float))) and isinstance(v,(float, int))):
return True
if ((type(t) == type) and (t == str)):
return isinstance(v,str)
isEnumType = ((type(t) == type) and (t == Enum))
if ((isEnumType and python_lib_Inspect.isclass(v)) and hasattr(v,"_hx_constructs")):
return True
if isEnumType:
return False
isClassType = ((type(t) == type) and (t == Class))
if ((((isClassType and (not isinstance(v,Enum))) and python_lib_Inspect.isclass(v)) and hasattr(v,"_hx_class_name")) and (not hasattr(v,"_hx_constructs"))):
return True
if isClassType:
return False
tmp = None
try:
tmp = isinstance(v,t)
except BaseException as _g:
None
tmp = False
if tmp:
return True
if python_lib_Inspect.isclass(t):
cls = t
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 = v.__class__
result = False
while (currentClass is not None):
if loop(currentClass):
result = True
break
currentClass = python_Boot.getSuperClass(currentClass)
return result
else:
return False
@staticmethod
def string(s):
return python_Boot.toString1(s,"")
@staticmethod
def parseInt(x):
if (x is None):
return None
try:
return int(x)
except BaseException as _g:
None
base = 10
_hx_len = len(x)
foundCount = 0
sign = 0
firstDigitIndex = 0
lastDigitIndex = -1
previous = 0
_g = 0
_g1 = _hx_len
while (_g < _g1):
i = _g
_g = (_g + 1)
c = (-1 if ((i >= len(x))) else ord(x[i]))
if (((c > 8) and ((c < 14))) or ((c == 32))):
if (foundCount > 0):
return None
continue
else:
c1 = c
if (c1 == 43):
if (foundCount == 0):
sign = 1
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (c1 == 45):
if (foundCount == 0):
sign = -1
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (c1 == 48):
if (not (((foundCount == 0) or (((foundCount == 1) and ((sign != 0))))))):
if (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif ((c1 == 120) or ((c1 == 88))):
if ((previous == 48) and ((((foundCount == 1) and ((sign == 0))) or (((foundCount == 2) and ((sign != 0))))))):
base = 16
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
if (((foundCount == 0) and ((sign == 0))) or (((foundCount == 1) and ((sign != 0))))):
firstDigitIndex = i
foundCount = (foundCount + 1)
lastDigitIndex = i
previous = c
if (firstDigitIndex <= lastDigitIndex):
digits = HxString.substring(x,firstDigitIndex,(lastDigitIndex + 1))
try:
return (((-1 if ((sign == -1)) else 1)) * int(digits,base))
except BaseException as _g:
return None
return None
class Float: pass
class Int: pass
class Bool: pass
class Dynamic: pass
2023-03-09 22:32:28 +01:00
class haxe_Exception(Exception):
_hx_class_name = "haxe.Exception"
__slots__ = ("_hx___nativeStack", "_hx___nativeException", "_hx___previousException")
_hx_fields = ["__nativeStack", "__nativeException", "__previousException"]
_hx_methods = ["unwrap"]
_hx_statics = ["caught"]
_hx_interfaces = []
_hx_super = Exception
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
def __init__(self,message,previous = None,native = None):
self._hx___previousException = None
self._hx___nativeException = None
self._hx___nativeStack = None
super().__init__(message)
self._hx___previousException = previous
if ((native is not None) and Std.isOfType(native,BaseException)):
self._hx___nativeException = native
self._hx___nativeStack = haxe_NativeStackTrace.exceptionStack()
2023-03-09 19:58:08 +01:00
else:
2023-03-09 22:32:28 +01:00
self._hx___nativeException = self
infos = python_lib_Traceback.extract_stack()
if (len(infos) != 0):
infos.pop()
infos.reverse()
self._hx___nativeStack = infos
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
def unwrap(self):
return self._hx___nativeException
2023-03-09 19:58:08 +01:00
@staticmethod
2023-03-09 22:32:28 +01:00
def caught(value):
if Std.isOfType(value,haxe_Exception):
return value
elif Std.isOfType(value,BaseException):
return haxe_Exception(str(value),None,value)
else:
return haxe_ValueException(value,None,value)
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
class haxe_NativeStackTrace:
_hx_class_name = "haxe.NativeStackTrace"
__slots__ = ()
_hx_statics = ["saveStack", "exceptionStack"]
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
@staticmethod
def saveStack(exception):
pass
2023-03-09 19:58:08 +01:00
@staticmethod
2023-03-09 22:32:28 +01:00
def exceptionStack():
exc = python_lib_Sys.exc_info()
if (exc[2] is not None):
infos = python_lib_Traceback.extract_tb(exc[2])
infos.reverse()
return infos
else:
return []
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
class haxe_ValueException(haxe_Exception):
_hx_class_name = "haxe.ValueException"
__slots__ = ("value",)
_hx_fields = ["value"]
_hx_methods = ["unwrap"]
_hx_statics = []
_hx_interfaces = []
_hx_super = haxe_Exception
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
def __init__(self,value,previous = None,native = None):
self.value = None
super().__init__(Std.string(value),previous,native)
self.value = value
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
def unwrap(self):
return self.value
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
class haxe_iterators_ArrayIterator:
_hx_class_name = "haxe.iterators.ArrayIterator"
__slots__ = ("array", "current")
_hx_fields = ["array", "current"]
2023-03-09 19:58:08 +01:00
_hx_methods = ["hasNext", "next"]
2023-03-09 22:32:28 +01:00
def __init__(self,array):
self.current = 0
self.array = array
2023-03-09 19:58:08 +01:00
def hasNext(self):
2023-03-09 22:32:28 +01:00
return (self.current < len(self.array))
2023-03-09 19:58:08 +01:00
def next(self):
2023-03-09 22:32:28 +01:00
def _hx_local_3():
def _hx_local_2():
_hx_local_0 = self
_hx_local_1 = _hx_local_0.current
_hx_local_0.current = (_hx_local_1 + 1)
return _hx_local_1
return python_internal_ArrayImpl._get(self.array, _hx_local_2())
return _hx_local_3()
2023-03-09 19:58:08 +01:00
2023-03-09 22:32:28 +01:00
class haxe_iterators_ArrayKeyValueIterator:
_hx_class_name = "haxe.iterators.ArrayKeyValueIterator"
__slots__ = ("current", "array")
_hx_fields = ["current", "array"]
2023-03-09 19:58:08 +01:00
_hx_methods = ["hasNext", "next"]
2023-03-09 22:32:28 +01:00
def __init__(self,array):
self.current = 0
self.array = array
2023-03-09 19:58:08 +01:00
def hasNext(self):
2023-03-09 22:32:28 +01:00
return (self.current < len(self.array))
2023-03-09 19:58:08 +01:00
def next(self):
2023-03-09 22:32:28 +01:00
def _hx_local_3():
def _hx_local_2():
_hx_local_0 = self
_hx_local_1 = _hx_local_0.current
_hx_local_0.current = (_hx_local_1 + 1)
return _hx_local_1
return _hx_AnonObject({'value': python_internal_ArrayImpl._get(self.array, self.current), 'key': _hx_local_2()})
return _hx_local_3()
2023-03-09 19:58:08 +01:00
class python_Boot:
_hx_class_name = "python.Boot"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_hx_statics = ["keywords", "toString1", "fields", "simpleField", "field", "getInstanceFields", "getSuperClass", "getClassFields", "prefixLength", "unhandleKeywords"]
2023-03-09 19:58:08 +01:00
@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 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 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 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 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
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):
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
class python_internal_ArrayImpl:
_hx_class_name = "python.internal.ArrayImpl"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_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"]
2023-03-09 19:58:08 +01:00
@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):
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
class HxOverrides:
_hx_class_name = "HxOverrides"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_hx_statics = ["eq", "stringOrNull", "push", "length", "arrayGet"]
2023-03-09 19:58:08 +01:00
@staticmethod
def eq(a,b):
if (isinstance(a,list) or isinstance(b,list)):
return a is b
return (a == b)
@staticmethod
2023-03-09 22:32:28 +01:00
def stringOrNull(s):
if (s is None):
return "null"
else:
return s
2023-03-09 19:58:08 +01:00
@staticmethod
def push(x,e):
if isinstance(x,list):
_this = x
_this.append(e)
return len(_this)
return x.push(e)
@staticmethod
def length(x):
if isinstance(x,str):
return len(x)
elif isinstance(x,list):
return len(x)
return x.length
@staticmethod
def arrayGet(a,i):
if isinstance(a,list):
x = a
if ((i > -1) and ((i < len(x)))):
return x[i]
else:
return None
else:
return a[i]
class python_internal_MethodClosure:
_hx_class_name = "python.internal.MethodClosure"
__slots__ = ("obj", "func")
_hx_fields = ["obj", "func"]
_hx_methods = ["__call__"]
def __init__(self,obj,func):
self.obj = obj
self.func = func
def __call__(self,*args):
return self.func(self.obj,*args)
class HxString:
_hx_class_name = "HxString"
__slots__ = ()
2023-03-09 22:32:28 +01:00
_hx_statics = ["split", "charCodeAt", "charAt", "lastIndexOf", "toUpperCase", "toLowerCase", "indexOf", "indexOfImpl", "toString", "get_length", "substring", "substr"]
2023-03-09 19:58:08 +01:00
@staticmethod
def split(s,d):
if (d == ""):
return list(s)
else:
return s.split(d)
@staticmethod
def charCodeAt(s,index):
if ((((s is None) or ((len(s) == 0))) or ((index < 0))) or ((index >= len(s)))):
return None
else:
return ord(s[index])
@staticmethod
def charAt(s,index):
if ((index < 0) or ((index >= len(s)))):
return ""
else:
return s[index]
@staticmethod
def lastIndexOf(s,_hx_str,startIndex = None):
if (startIndex is None):
return s.rfind(_hx_str, 0, len(s))
elif (_hx_str == ""):
length = len(s)
if (startIndex < 0):
startIndex = (length + startIndex)
if (startIndex < 0):
startIndex = 0
if (startIndex > length):
return length
else:
return startIndex
else:
i = s.rfind(_hx_str, 0, (startIndex + 1))
startLeft = (max(0,((startIndex + 1) - len(_hx_str))) if ((i == -1)) else (i + 1))
check = s.find(_hx_str, startLeft, len(s))
if ((check > i) and ((check <= startIndex))):
return check
else:
return i
@staticmethod
def toUpperCase(s):
return s.upper()
@staticmethod
def toLowerCase(s):
return s.lower()
@staticmethod
def indexOf(s,_hx_str,startIndex = None):
if (startIndex is None):
return s.find(_hx_str)
else:
return HxString.indexOfImpl(s,_hx_str,startIndex)
@staticmethod
def indexOfImpl(s,_hx_str,startIndex):
if (_hx_str == ""):
length = len(s)
if (startIndex < 0):
startIndex = (length + startIndex)
if (startIndex < 0):
startIndex = 0
if (startIndex > length):
return length
else:
return startIndex
return s.find(_hx_str, startIndex)
@staticmethod
def toString(s):
return s
@staticmethod
def get_length(s):
return len(s)
@staticmethod
def substring(s,startIndex,endIndex = None):
if (startIndex < 0):
startIndex = 0
if (endIndex is None):
return s[startIndex:]
else:
if (endIndex < 0):
endIndex = 0
if (endIndex < startIndex):
return s[endIndex:startIndex]
else:
return s[startIndex:endIndex]
@staticmethod
def substr(s,startIndex,_hx_len = None):
if (_hx_len is None):
return s[startIndex:]
else:
if (_hx_len == 0):
return ""
if (startIndex < 0):
startIndex = (len(s) + startIndex)
if (startIndex < 0):
startIndex = 0
return s[startIndex:(startIndex + _hx_len)]
class xrfragment_Query:
_hx_class_name = "xrfragment.Query"
__slots__ = ("str", "q", "include", "exclude", "accept", "preset")
_hx_fields = ["str", "q", "include", "exclude", "accept", "preset"]
2023-03-17 16:06:24 +01:00
_hx_methods = ["toObject", "selected", "parse", "test"]
2023-03-09 19:58:08 +01:00
def __init__(self,_hx_str):
self.preset = ""
self.accept = False
self.exclude = list()
self.include = list()
self.q = _hx_AnonObject({})
self.str = ""
if (_hx_str is not None):
self.parse(_hx_str)
def toObject(self):
return self.q
2023-03-17 16:06:24 +01:00
def selected(self,nodename):
2023-03-09 19:58:08 +01:00
if Reflect.field(self.q,"copy_all"):
self.accept = True
if (nodename in self.include):
self.accept = True
if (nodename in self.exclude):
self.accept = False
return self.accept
def parse(self,_hx_str,recurse = None):
if (recurse is None):
recurse = False
_gthis = self
copyAll = (Reflect.field(self.q,"copy_all") if recurse else (((HxString.substr(_hx_str,0,1) == "-") or ((HxString.substr(_hx_str,0,1) == "?"))) or ((_hx_str == ""))))
isOr = EReg("^or$","")
isProp = EReg(".*:[><=!]?","")
isName = EReg("[^:/]","")
isExclude = EReg("^-","")
isInclude = EReg("^\\+","")
isPreset = EReg("^\\?","")
token = _hx_str.split(" ")
ors = list()
q = _hx_AnonObject({})
def _hx_local_0():
nonlocal q
q = _hx_AnonObject({})
value = list()
setattr(q,(("_hx_" + "object") if (("object" in python_Boot.keywords)) else (("_hx_" + "object") if (((((len("object") > 2) and ((ord("object"[0]) == 95))) and ((ord("object"[1]) == 95))) and ((ord("object"[(len("object") - 1)]) != 95)))) else "object")),value)
value = list()
setattr(q,(("_hx_" + "-object") if (("-object" in python_Boot.keywords)) else (("_hx_" + "-object") if (((((len("-object") > 2) and ((ord("-object"[0]) == 95))) and ((ord("-object"[1]) == 95))) and ((ord("-object"[(len("-object") - 1)]) != 95)))) else "-object")),value)
ors.append(q)
return q
composeQuery = _hx_local_0
composeQuery()
match = None
def _hx_local_2(_hx_str,prefix = None):
if (prefix is None):
prefix = ""
isPreset.matchObj = python_lib_Re.search(isPreset.pattern,_hx_str)
if ((isPreset.matchObj is not None) and (not recurse)):
_gthis.preset = _hx_str
return
match1 = None
isExclude.matchObj = python_lib_Re.search(isExclude.pattern,_hx_str)
if (isExclude.matchObj is None):
isInclude.matchObj = python_lib_Re.search(isInclude.pattern,_hx_str)
match1 = (isInclude.matchObj is not None)
else:
match1 = True
if match1:
t = HxString.substr(_hx_str,1,None)
match(t,HxString.substr(_hx_str,0,1))
return
isProp.matchObj = python_lib_Re.search(isProp.pattern,_hx_str)
if (isProp.matchObj is not None):
skip = 0
_hx_type = "="
startIndex = None
if (((_hx_str.find("*") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"*",startIndex))) != -1):
_hx_type = "*"
startIndex = None
if (((_hx_str.find(">") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,">",startIndex))) != -1):
_hx_type = ">"
startIndex = None
if (((_hx_str.find("<") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"<",startIndex))) != -1):
_hx_type = "<"
startIndex = None
if (((_hx_str.find("!=") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"!=",startIndex))) != -1):
_hx_type = "!="
startIndex = None
if (((_hx_str.find(">=") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,">=",startIndex))) != -1):
_hx_type = ">="
startIndex = None
if (((_hx_str.find("<=") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"<=",startIndex))) != -1):
_hx_type = "<="
if (_hx_type != "="):
skip = (skip + len(_hx_type))
property = HxOverrides.arrayGet(_hx_str.split(":"), 0)
value = None
if Reflect.field(q,(("null" if prefix is None else prefix) + ("null" if property is None else property))):
value = Reflect.field(q,(("null" if prefix is None else prefix) + ("null" if property is None else property)))
else:
value = _hx_AnonObject({})
value1 = HxString.substr(HxOverrides.arrayGet(_hx_str.split(":"), 1),skip,None)
setattr(value,(("_hx_" + _hx_type) if ((_hx_type in python_Boot.keywords)) else (("_hx_" + _hx_type) if (((((len(_hx_type) > 2) and ((ord(_hx_type[0]) == 95))) and ((ord(_hx_type[1]) == 95))) and ((ord(_hx_type[(len(_hx_type) - 1)]) != 95)))) else _hx_type)),value1)
key = (("null" if prefix is None else prefix) + ("null" if property is None else property))
setattr(q,(("_hx_" + key) if ((key in python_Boot.keywords)) else (("_hx_" + key) if (((((len(key) > 2) and ((ord(key[0]) == 95))) and ((ord(key[1]) == 95))) and ((ord(key[(len(key) - 1)]) != 95)))) else key)),value)
return
isName.matchObj = python_lib_Re.search(isName.pattern,_hx_str)
if (isName.matchObj is not None):
if (prefix == "-"):
Reflect.field(Reflect.field(q,"-object"),"push")(_hx_str)
while (Reflect.field(Reflect.field(q,"object"),"contains")(_hx_str) == True):
Reflect.field(Reflect.field(q,"object"),"remove")(_hx_str)
else:
Reflect.field(Reflect.field(q,"object"),"push")(_hx_str)
while (Reflect.field(Reflect.field(q,"-object"),"contains")(_hx_str) == True):
Reflect.field(Reflect.field(q,"-object"),"remove")(_hx_str)
return
match = _hx_local_2
_g = 0
_g1 = len(token)
while (_g < _g1):
i = _g
_g = (_g + 1)
isOr.matchObj = python_lib_Re.search(isOr.pattern,(token[i] if i >= 0 and i < len(token) else None))
if (isOr.matchObj is not None):
composeQuery()
else:
match((token[i] if i >= 0 and i < len(token) else None))
_g = 0
_g1 = len(ors)
while (_g < _g1):
i = _g
_g = (_g + 1)
_hx_or = (ors[i] if i >= 0 and i < len(ors) else None)
if (Reflect.field(_hx_or,"object") is not None):
self.include = (self.include + Reflect.field(_hx_or,"object"))
if (Reflect.field(_hx_or,"-object") is not None):
self.exclude = (self.exclude + Reflect.field(_hx_or,"-object"))
self.q = _hx_AnonObject({'_hx_or': ors, 'copy_all': copyAll})
return self.q
def test(self,property,value = None):
if (self.preset == property):
self.parse(value,True)
_g = 0
_g1 = Reflect.field(Reflect.field(self.q,"or"),"length")
while (_g < _g1):
i = _g
_g = (_g + 1)
_hx_or = HxOverrides.arrayGet(Reflect.field(self.q,"or"), i)
conds = [0]
fails = [0]
_hx_pass = 0
def _hx_local_7(fails,conds):
def _hx_local_0(expr):
_hx_local_1 = conds
_hx_local_2 = 0
_hx_local_3 = (_hx_local_1[_hx_local_2] if _hx_local_2 >= 0 and _hx_local_2 < len(_hx_local_1) else None)
python_internal_ArrayImpl._set(_hx_local_1, _hx_local_2, (_hx_local_3 + 1))
(_hx_local_1[_hx_local_2] if _hx_local_2 >= 0 and _hx_local_2 < len(_hx_local_1) else None)
_hx_local_4 = fails
_hx_local_5 = 0
_hx_local_6 = (_hx_local_4[_hx_local_5] if _hx_local_5 >= 0 and _hx_local_5 < len(_hx_local_4) else None)
python_internal_ArrayImpl._set(_hx_local_4, _hx_local_5, (_hx_local_6 + (0 if expr else 1)))
(_hx_local_4[_hx_local_5] if _hx_local_5 >= 0 and _hx_local_5 < len(_hx_local_4) else None)
return expr
return _hx_local_0
when = _hx_local_7(fails,conds)
_g2 = 0
_g3 = python_Boot.fields(_hx_or)
while (_g2 < len(_g3)):
k = (_g3[_g2] if _g2 >= 0 and _g2 < len(_g3) else None)
_g2 = (_g2 + 1)
orval = Reflect.field(_hx_or,k)
if (k != property):
continue
if ((Reflect.field(orval,"=") is not None) and when(HxOverrides.eq(value,Reflect.field(orval,"=")))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,"*") is not None) and when((value is not None))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,">") is not None) and when((value > Std.parseInt(Reflect.field(orval,">"))))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,"<") is not None) and when((value < Std.parseInt(Reflect.field(orval,"<"))))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,">=") is not None) and when((value >= Std.parseInt(Reflect.field(orval,">="))))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,"<=") is not None) and when((value >= Std.parseInt(Reflect.field(orval,"<="))))):
_hx_pass = (_hx_pass + 1)
if ((Reflect.field(orval,"!=") is not None) and when((value != Std.parseInt(Reflect.field(orval,"!="))))):
_hx_pass = (_hx_pass + 1)
if ((self.accept and (((conds[0] if 0 < len(conds) else None) > 0))) and (((fails[0] if 0 < len(fails) else None) > 0))):
self.accept = False
if ((((conds[0] if 0 < len(conds) else None) > 0) and ((_hx_pass > 0))) and (((fails[0] if 0 < len(fails) else None) == 0))):
self.accept = True
Math.NEGATIVE_INFINITY = float("-inf")
Math.POSITIVE_INFINITY = float("inf")
Math.NaN = float("nan")
Math.PI = python_lib_Math.pi
python_Boot.keywords = set(["and", "del", "from", "not", "with", "as", "elif", "global", "or", "yield", "assert", "else", "if", "pass", "None", "break", "except", "import", "raise", "True", "class", "exec", "in", "return", "False", "continue", "finally", "is", "try", "def", "for", "lambda", "while"])
2023-03-09 22:32:28 +01:00
python_Boot.prefixLength = len("_hx_")