add multi_apps; update chrome utilities
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .chrome import is_expected_tabs, is_expected_bookmarks, compare_pdfs, is_cookie_deleted, is_shortcut_on_desktop, check_font_size, \
|
||||
check_enabled_experiments, check_history_deleted
|
||||
check_enabled_experiments, check_history_deleted, is_expected_search_query
|
||||
from .docs import compare_font_names, compare_subscript_contains, has_page_numbers_in_footers, compare_docx_lines
|
||||
from .docs import find_default_font, contains_page_break, compare_docx_files, compare_docx_tables, compare_line_spacing, \
|
||||
compare_insert_equation, compare_highlighted_text
|
||||
@@ -20,4 +20,4 @@ from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
|
||||
from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, compare_images, compare_audios, \
|
||||
compare_videos, check_qt_bgcone, check_one_instance_when_started_from_file,check_qt_minimal_view, check_qt_max_volume, \
|
||||
check_qt_slider_colours, check_global_key_play_pause
|
||||
from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed, check_json_settings, check_json_keybindings
|
||||
from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed, check_json_settings, check_json_keybindings
|
||||
@@ -1,4 +1,4 @@
|
||||
import logging
|
||||
import logging, re
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import fitz # PyMuPDF
|
||||
@@ -44,6 +44,15 @@ def is_expected_bookmarks(bookmarks: List[str], rule: Dict[str, Any]) -> float:
|
||||
raise TypeError(f"{rule['type']} not support yet!")
|
||||
|
||||
|
||||
def is_expected_search_query(active_tab_info: Dict[str, str], rules: Dict[str, Any]) -> float:
|
||||
expected = rules['expect']
|
||||
pattern = expected['pattern']
|
||||
matched = re.search(pattern, active_tab_info['url'])
|
||||
if matched:
|
||||
return 1.
|
||||
return 0.
|
||||
|
||||
|
||||
def compare_pdfs(pdf1_path, pdf2_path):
|
||||
"""
|
||||
Compare two PDF files.
|
||||
@@ -56,11 +65,14 @@ def compare_pdfs(pdf1_path, pdf2_path):
|
||||
for page in pdf:
|
||||
text += page.get_text()
|
||||
return text.strip()
|
||||
try:
|
||||
text1 = extract_text_from_pdf(pdf1_path)
|
||||
text2 = extract_text_from_pdf(pdf2_path)
|
||||
|
||||
text1 = extract_text_from_pdf(pdf1_path)
|
||||
text2 = extract_text_from_pdf(pdf2_path)
|
||||
|
||||
return fuzz.ratio(text1, text2) / 100
|
||||
return fuzz.ratio(text1, text2) / 100
|
||||
except Exception as e:
|
||||
logger.info(f"[ERROR]: unexpected error occurred when comparing PDF files: {e}")
|
||||
return 0.0
|
||||
|
||||
|
||||
def is_cookie_deleted(cookie_data, rule):
|
||||
|
||||
Reference in New Issue
Block a user