# Path: hamster_gtk/helpers.py
# def _u(string):
# def show_error(parent, error, message=None):
# def clear_children(widget):
# def get_parent_window(widget):
# def calendar_date_to_datetime(date):
# def decompose_raw_fact_string(text, raw=False):
# def get_delta_string(delta):
# def rgb_to_gtk_rgb(r, g, b):
# 
# Path: hamster_gtk/helpers.py
# def _u(string):
#     """
#     Return passed string as a text instance.
# 
#     This helper is particularly useful to wrap Gtk 'string return values' as
#     they depend on the used python version. On python 2 Gtk will return utf-8
#     encoded bytestrings while on python 3 it will return 'unicode strings'.
# 
#     The reason we have to use this and not ``six.u`` is that six does not make
#     assumptions about the encoding and hence can not be used to safely decode
#     non ascii bytestrings into unicode.
# 
#     Args:
#         string (str): A string instance. On ``py2`` this will be a bytestring,
#             on ``py3`` a 'unicode string'.
# 
#     Returns:
#         text_type: Returns a 'unicode text type'. Under ``py2`` that means a
#         ``unicode`` instance, under ``py3`` this will be a ``str`` instance.
#     """
#     if six.PY2:
#         return string.decode('utf-8')
#     else:
#         return string


import datetime
from gi.repository import GObject, Gtk
from orderedset import OrderedSet
from six import text_type
from hamster_gtk import helpers
from hamster_gtk.helpers import _u
    def _match_anywhere(self, completion, entrystr, iter, data):
        """
        Check if the entrystring is a substring of our text_column.

        Args:
            entrystr (str): The text extracted from the entry so far. Note that
                we do not use this at all. Instead we fetch
                ``self.get_entry().get_segment_text`` in order to get only the text
                of the currently edited segment.
            iter: Iterator position indicating the model row we check against.
                This works because
                ``self.get_entry()._on_changed`` makes sure that the completion
                model is set properly according to ``self.get_entry().current_segment``.
            data: Arbitrary user data.

        Returns:
            bool: ``True`` if ``self.get_entry.get_segment_text`` is a substring,
                ``False`` if not.

        Note this is a custom match function, for details on the general generic
        solution [please see|https://lazka.github.io/pgi-docs/#Gtk-3.0/
        callbacks.html#Gtk.EntryCompletionMatchFunc].
        """
        result = False
        entry = self.get_entry()
        modelstring = ''
        hit = self.get_model()[iter][0]
        # We only need to check if the string was matched at all. Otherwise
        # there are no 'segments' anyway.
        if hit and entry.match:

# Path: hamster_gtk/helpers.py
# def _u(string):
# def show_error(parent, error, message=None):
# def clear_children(widget):
# def get_parent_window(widget):
# def calendar_date_to_datetime(date):
# def decompose_raw_fact_string(text, raw=False):
# def get_delta_string(delta):
# def rgb_to_gtk_rgb(r, g, b):
# 
# Path: hamster_gtk/helpers.py
# def _u(string):
#     """
#     Return passed string as a text instance.
# 
#     This helper is particularly useful to wrap Gtk 'string return values' as
#     they depend on the used python version. On python 2 Gtk will return utf-8
#     encoded bytestrings while on python 3 it will return 'unicode strings'.
# 
#     The reason we have to use this and not ``six.u`` is that six does not make
#     assumptions about the encoding and hence can not be used to safely decode
#     non ascii bytestrings into unicode.
# 
#     Args:
#         string (str): A string instance. On ``py2`` this will be a bytestring,
#             on ``py3`` a 'unicode string'.
# 
#     Returns:
#         text_type: Returns a 'unicode text type'. Under ``py2`` that means a
#         ``unicode`` instance, under ``py3`` this will be a ``str`` instance.
#     """
#     if six.PY2:
#         return string.decode('utf-8')
#     else:
#         return string


# Path: hamster_gtk/misc/widgets/raw_fact_entry.py
import datetime
from gi.repository import GObject, Gtk
from orderedset import OrderedSet
from six import text_type
from hamster_gtk import helpers
from hamster_gtk.helpers import _u

    def _match_anywhere(self, completion, entrystr, iter, data):
        """
        Check if the entrystring is a substring of our text_column.

        Args:
            entrystr (str): The text extracted from the entry so far. Note that
                we do not use this at all. Instead we fetch
                ``self.get_entry().get_segment_text`` in order to get only the text
                of the currently edited segment.
            iter: Iterator position indicating the model row we check against.
                This works because
                ``self.get_entry()._on_changed`` makes sure that the completion
                model is set properly according to ``self.get_entry().current_segment``.
            data: Arbitrary user data.

        Returns:
            bool: ``True`` if ``self.get_entry.get_segment_text`` is a substring,
                ``False`` if not.

        Note this is a custom match function, for details on the general generic
        solution [please see|https://lazka.github.io/pgi-docs/#Gtk-3.0/
        callbacks.html#Gtk.EntryCompletionMatchFunc].
        """
        result = False
        entry = self.get_entry()
        modelstring = ''
        hit = self.get_model()[iter][0]
        # We only need to check if the string was matched at all. Otherwise
        # there are no 'segments' anyway.
        if hit and entry.match:

            modelstring = _u(hit)