AutoFramework/main3.py

114 lines
2.9 KiB
Python

# str0 = '''"it in the ..." in $['content']'''
#
# str1 = '''"it in the ..." in $['content']'''
# str2 = '''$['content'] == "ha in the end."'''
# str3 = '''"it in the ..." in $'''
# str4 = """$w.dasfd[9][0] in 'it in the ...'"""
# str5 = '''$.flag == true'''
#
# import re
#
#
# str41 = """$w.dasfd[9][0] in 'it in the ...'"""
# str42 = '''$w.dasfd[9][0] in "it in the ..."'''
# str43 = """$w.dasfd['a']['vf'] in 'it in the ...'"""
# str44 = """$w.dasfd['a']['vf in '] in true"""
# str45 = """$null in true"""
# str46 = "$w.dasfd['a']['vf in '] in \"true\""
#
#
#
# s1 = """$data['info'] in 'it in the end...'"""
# s2 = """$data[0] in 'it in the end...'"""
# s3 = """$data['info']["name"] in 'it in the end...'"""
# s4 = """'info' in 'it in the end...'"""
# s41 = '''"info" in "it in the end..."'''
# s5 = '''"it in the ..." in $data[0]'''
# s6 = '''true in $data[0]'''
#
#
#
#
#
#
#
#
#
# s = str2
# print(re.findall('([\"].*?[\"].*?[\s]*)( in )([\s]*.*$)', s))
# print(re.findall('([\'].*?[\'].*?[\s]*)( in )([\s]*.*$)', s))
# print(re.findall('[\s]*( in )[\s]*.*?[\"].*?[\"]', s))
# print(re.findall('[\s]*( in )[\s]*.*?[\'].*?[\']', s))
# print(re.findall('(^(?!.*[\'\"]).*[\s]*)( in )([\s]*.*?(?!.*[\'\"]).*$)', s))
#
#
# print(re.findall('(^(?!.*[\'\"]).*[\s]*)( in )([\s]*.*?(?!.*[\'\"]).*$)', '''$data_1['info'] in " t he end.[ c ] "'''))
#
#
# print(re.findall('(^.*[\'\"]*.*[\'\"]*.*[\s]*)( in )([\s]*.*[\'\"]*.*[\'\"]*.*$)', s4))
# ?
# print(re.compile(' in ').sub(' IN ', str1))
string = '"it in the ..." in "..."'
def _parse_formula(text, operator):
locals().__setitem__('quota', 0)
none_quota = []
none_range = []
for i in range(len(text)):
this = text[i]
match this:
case '\'':
match locals().get('quota'):
case 0:
locals().__setitem__('quota', 1)
case 1:
locals().__setitem__('quota', 0)
case '\"':
match locals().get('quota'):
case 0:
locals().__setitem__('quota', 2)
case 2:
locals().__setitem__('quota', 0)
case _:
match locals().get('quota'):
case 0:
none_quota.append(i)
for i in range(len(none_quota) + 1):
last = (i > 0 and none_quota[i-1]) or -1
this = (i < len(none_quota) and none_quota[i]) or 9999
if (this - last) > 1:
none_range.append(last)
none_range.append(this)
none_range.pop(0)
none_range.pop(-1)
none_range_list = []
for i in range(int(len(none_range)/2)):
none_range_list.append([none_range[i*2], none_range[i*2+1]])
for v in none_range_list:
p = text.find(operator, v[0], v[1]+1)
if not p == -1:
return [text[:p], text[p+len(operator):]]
else:
return False
print(func('$data["info"][0] == true'))