Skip to content

Commit 3c10e72

Browse files
committed
Improve culebra fill auto regex pattern
- Enable keto by default on generated files
1 parent 302d72f commit 3c10e72

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tools/culebra

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ ___________________/ /__/ /__/ /__/ /________________________________
2323
from __future__ import print_function
2424

2525
import textwrap
26+
from typing import Pattern
2627

2728
import culebratester_client
2829
from culebratester_client import WindowHierarchy, Selector
2930

30-
__version__ = '22.7.1'
31+
__version__ = '22.7.2'
3132

3233
import calendar
3334
import codecs
@@ -76,20 +77,17 @@ class Descriptor:
7677
return Descriptor.ID
7778

7879

79-
def fillAutoRegexpsRes():
80-
are = {'clock': re.compile(r'[012]?\d:[0-5]\d( [AP]M)*')}
81-
d = "("
82-
for i in range(7):
83-
d += calendar.day_abbr[i]
84-
if i != 6:
85-
d += '|'
86-
d += '), ('
87-
for i in range(1, 13):
88-
d += calendar.month_name[i]
89-
if i != 12:
90-
d += '|'
91-
d += r') [0123]\d'
92-
are['date'] = re.compile(d, re.IGNORECASE)
80+
def fillAutoRegexpsRes() -> dict[str, Pattern[str]]:
81+
"""
82+
Fills a map with the pre-configured auto regexps.
83+
:return: the dictionary
84+
:rtype: dict
85+
"""
86+
are = {'clock': re.compile(r'[012]?\d:[0-5]\d([ \u200a][AP]M)*')}
87+
d = fr"({'|'.join(calendar.day_abbr)}), ({'|'.join(calendar.month_abbr[1:])}) [0123]?\d"
88+
are["date_abbr"] = re.compile(d, re.IGNORECASE)
89+
d = fr"({'|'.join(calendar.day_name)}), ({'|'.join(calendar.month_name[1:])}) [0123]?\d"
90+
are["date"] = re.compile(d, re.IGNORECASE)
9391
are['battery'] = re.compile(r'Charging, \d\d%')
9492
are['temp'] = re.compile(r'\d+°')
9593
return are
@@ -917,7 +915,7 @@ def searchAndReplaceByRegexIfMatches(_s: str) -> str:
917915
:rtype: str
918916
"""
919917
for _are in [CulebraOptions.AUTO_REGEXPS_RES[k] for k in options[CulebraOptions.AUTO_REGEXPS]]:
920-
if _are.match(escapeRegexpSpecialChars(_s)):
918+
if _are.match(_s):
921919
return f"Pattern:{_are.pattern}"
922920
return _s
923921

@@ -1642,6 +1640,8 @@ vc = ViewClient(device, serialno, **kwargs2)
16421640

16431641
if kwargs2[ViewClientOptions.USE_UIAUTOMATOR_HELPER]:
16441642
print('''helper = vc.uiAutomatorHelper''')
1643+
print('''# set enabled to False if you don't want kato to find the closet selectors if one is not found''')
1644+
print('''helper.kato.enabled = True''')
16451645
if options[CulebraOptions.USE_DICTIONARY]:
16461646
print('''views = dict()''')
16471647
if options[CulebraOptions.SAVE_SCREENSHOT]:

0 commit comments

Comments
 (0)