Fix examples, and evaluation on Chrome, handle corner cases; Initialize arm support
This commit is contained in:
@@ -17,11 +17,17 @@ def is_expected_active_tab(active_tab_info: Dict[str, str], rule: Dict[str, Any]
|
||||
"""
|
||||
Checks if the expected active tab is open in Chrome.
|
||||
"""
|
||||
if not active_tab_info:
|
||||
return 0.
|
||||
|
||||
match_type = rule['type']
|
||||
|
||||
if match_type == "url":
|
||||
expected_url = rule['url']
|
||||
actual_url = active_tab_info.get('url', None)
|
||||
if isinstance(active_tab_info, Dict):
|
||||
actual_url = active_tab_info.get('url', None)
|
||||
else:
|
||||
actual_url = active_tab_info
|
||||
print("expected_url: {}".format(expected_url))
|
||||
print("actual_url: {}".format(actual_url))
|
||||
return 1 if compare_urls(expected_url, actual_url) else 0
|
||||
@@ -29,13 +35,17 @@ def is_expected_active_tab(active_tab_info: Dict[str, str], rule: Dict[str, Any]
|
||||
logger.error(f"Unknown type: {match_type}")
|
||||
return 0
|
||||
|
||||
|
||||
# rules[expected] is a string-formatted regex
|
||||
def is_expected_url_pattern_match(result, rules) -> float:
|
||||
"""
|
||||
This function is used to search the expected pattern in the url using regex.
|
||||
result is the return value of function "activte_tab_info" or return value of function "get_active_url_from_accessTree"
|
||||
"""
|
||||
if type(result)== dict:
|
||||
if not result:
|
||||
return 0.
|
||||
|
||||
if type(result) == dict:
|
||||
result_url = result["url"]
|
||||
print("result url: {}".format(result_url))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user