<commit_before># coding: utf-8
"""Main stb-tester python module. Intended to be used with `stbt run`.

See `man stbt` and http://stb-tester.com for documentation.

Copyright 2012-2013 YouView TV Ltd and contributors.
License: LGPL v2.1 or (at your option) any later version (see
https://github.com/stb-tester/stb-tester/blob/master/LICENSE for details).
"""

from __future__ import absolute_import

import argparse
import datetime
import functools
import glob
import inspect
import os
import Queue
import re
import subprocess
import threading
import time
import traceback
import warnings
from collections import deque, namedtuple
from contextlib import contextmanager
from distutils.version import LooseVersion

import cv2
import gi
import numpy
from enum import IntEnum
from kitchen.text.converters import to_bytes

from _stbt import logging, utils
from _stbt.config import ConfigurationError, get_config
from _stbt.gst_hacks import gst_iterate, map_gst_sample
from _stbt.logging import ddebug, debug, warn

gi.require_version("Gst", "1.0")
from gi.repository import GLib, GObject, Gst  # isort:skip pylint: disable=E0611

if getattr(gi, "version_info", (0, 0, 0)) < (3, 12, 0):
    GObject.threads_init()
Gst.init(None)

warnings.filterwarnings(
    action="always", category=DeprecationWarning, message='.*stb-tester')


# Functions available to stbt scripts
# ===========================================================================


class MatchParameters(object):
    """Parameters to customise the image processing algorithm used by
    `match`, `wait_for_match`, and `press_until_match`.<commit_msg>_stbt.core: Remove GObject.threads_init for ancient versions of GObject<commit_after># coding: utf-8
"""Main stb-tester python module. Intended to be used with `stbt run`.

See `man stbt` and http://stb-tester.com for documentation.

Copyright 2012-2013 YouView TV Ltd and contributors.
License: LGPL v2.1 or (at your option) any later version (see
https://github.com/stb-tester/stb-tester/blob/master/LICENSE for details).
"""

from __future__ import absolute_import

import argparse
import datetime
import functools
import glob
import inspect
import os
import Queue
import re
import subprocess
import threading
import time
import traceback
import warnings
from collections import deque, namedtuple
from contextlib import contextmanager
from distutils.version import LooseVersion

import cv2
import gi
import numpy
from enum import IntEnum
from kitchen.text.converters import to_bytes

from _stbt import logging, utils
from _stbt.config import ConfigurationError, get_config
from _stbt.gst_hacks import gst_iterate, map_gst_sample
from _stbt.logging import ddebug, debug, warn

gi.require_version("Gst", "1.0")
from gi.repository import GLib, GObject, Gst  # isort:skip pylint: disable=E0611

Gst.init(None)

warnings.filterwarnings(
    action="always", category=DeprecationWarning, message='.*stb-tester')


# Functions available to stbt scripts
# ===========================================================================


class MatchParameters(object):
    """Parameters to customise the image processing algorithm used by
    `match`, `wait_for_match`, and `press_until_match`.
{'fraction_non_alphanumeric': 0.12143974960876369, 'fraction_numerical': 0.013458528951486698, 'mean_word_length': 5.771186440677966, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3982856', 'n_tokens_mistral': 960, 'n_tokens_neox': 918, 'n_words': 328}