# Path: pyanaconda/localization.py
# LOCALE_CONF_FILE_PATH = "/etc/locale.conf"
# LANGCODE_RE = re.compile(r'(?P<language>[A-Za-z]+)'
#                          r'(_(?P<territory>[A-Za-z]+))?'
#                          r'(\.(?P<encoding>[-A-Za-z0-9]+))?'
#                          r'(@(?P<script>[-A-Za-z0-9]+))?')
# class LocalizationConfigError(Exception):
# class InvalidLocaleSpec(LocalizationConfigError):
# def parse_langcode(langcode):
# def is_supported_locale(locale):
# def langcode_matches_locale(langcode, locale):
# def find_best_locale_match(locale, langcodes):
#     def get_match_score(locale, langcode):
# def setup_locale(locale, lang=None):
# def get_english_name(locale):
# def get_native_name(locale):
# def get_available_translations(localedir=None):
# def get_language_locales(lang):
# def get_territory_locales(territory):
# def get_locale_keyboards(locale):
# def get_locale_timezones(locale):
# def get_locale_territory(locale):
# def get_xlated_timezone(tz_spec_part):
# def write_language_configuration(lang, root):
# def load_firmware_language(lang):
# 
# Path: pyanaconda/iutil.py
# def strip_accents(s):
#     """This function takes arbitrary unicode string
#     and returns it with all the diacritics removed.
# 
#     :param s: arbitrary string
#     :type s: unicode
# 
#     :return: s with diacritics removed
#     :rtype: unicode
# 
#     """
#     return ''.join((c for c in unicodedata.normalize('NFD', s)
#                       if unicodedata.category(c) != 'Mn'))
# 
# Path: pyanaconda/ui/gui/utils.py
# def set_treeview_selection(treeview, item, col=0):
#     """
#     Select the given item in the given treeview and scroll to it.
# 
#     :param treeview: treeview to select and item in
#     :type treeview: GtkTreeView
#     :param item: item to be selected
#     :type item: str
#     :param col: column to search for the item in
#     :type col: int
#     :return: selected iterator or None if item was not found
#     :rtype: GtkTreeIter or None
# 
#     """
# 
#     model = treeview.get_model()
#     itr = model.get_iter_first()
#     while itr and not model[itr][col] == item:
#         itr = model.iter_next(itr)
# 
#     if not itr:
#         # item not found, cannot be selected
#         return None
# 
#     # otherwise select the item and scroll to it
#     selection = treeview.get_selection()
#     selection.select_iter(itr)
#     path = model.get_path(itr)
# 
#     # row_align=0.5 tells GTK to move the cell to the middle of the
#     # treeview viewport (0.0 should align it with the top, 1.0 with bottom)
#     # If the cell is the uppermost one, it should align it with the top
#     # of the viewport.
#     #
#     # Unfortunately, this does not work as expected due to a bug in GTK.
#     # (see rhbz#970048)
#     treeview.scroll_to_cell(path, use_align=True, row_align=0.5)
# 
#     return itr


from gi.repository import Gtk, Pango
from pyanaconda import localization
from pyanaconda.iutil import strip_accents
from pyanaconda.ui.gui.utils import set_treeview_selection
    def _add_language(self, store, native, english, lang):
        """Override this method with a valid implementation"""

        raise NotImplementedError()

    def _add_locale(self, store, native, locale):
        """Override this method with a valid implementation"""

        raise NotImplementedError()

    def _select_locale(self, locale):
        """
        Try to select the given locale in the language and locale
        treeviews. This method tries to find the best match for the given
        locale.

        :return: a pair of selected iterators (language and locale)
        :rtype: a pair of GtkTreeIter or None objects

        """

        # get lang and select it
        parts = localization.parse_langcode(locale)
        if "language" not in parts:
            # invalid locale, cannot select
            return (None, None)

        lang_itr = set_treeview_selection(self._langView, parts["language"], col=2)

        # find matches and use the one with the highest rank

# Path: pyanaconda/localization.py
# LOCALE_CONF_FILE_PATH = "/etc/locale.conf"
# LANGCODE_RE = re.compile(r'(?P<language>[A-Za-z]+)'
#                          r'(_(?P<territory>[A-Za-z]+))?'
#                          r'(\.(?P<encoding>[-A-Za-z0-9]+))?'
#                          r'(@(?P<script>[-A-Za-z0-9]+))?')
# class LocalizationConfigError(Exception):
# class InvalidLocaleSpec(LocalizationConfigError):
# def parse_langcode(langcode):
# def is_supported_locale(locale):
# def langcode_matches_locale(langcode, locale):
# def find_best_locale_match(locale, langcodes):
#     def get_match_score(locale, langcode):
# def setup_locale(locale, lang=None):
# def get_english_name(locale):
# def get_native_name(locale):
# def get_available_translations(localedir=None):
# def get_language_locales(lang):
# def get_territory_locales(territory):
# def get_locale_keyboards(locale):
# def get_locale_timezones(locale):
# def get_locale_territory(locale):
# def get_xlated_timezone(tz_spec_part):
# def write_language_configuration(lang, root):
# def load_firmware_language(lang):
# 
# Path: pyanaconda/iutil.py
# def strip_accents(s):
#     """This function takes arbitrary unicode string
#     and returns it with all the diacritics removed.
# 
#     :param s: arbitrary string
#     :type s: unicode
# 
#     :return: s with diacritics removed
#     :rtype: unicode
# 
#     """
#     return ''.join((c for c in unicodedata.normalize('NFD', s)
#                       if unicodedata.category(c) != 'Mn'))
# 
# Path: pyanaconda/ui/gui/utils.py
# def set_treeview_selection(treeview, item, col=0):
#     """
#     Select the given item in the given treeview and scroll to it.
# 
#     :param treeview: treeview to select and item in
#     :type treeview: GtkTreeView
#     :param item: item to be selected
#     :type item: str
#     :param col: column to search for the item in
#     :type col: int
#     :return: selected iterator or None if item was not found
#     :rtype: GtkTreeIter or None
# 
#     """
# 
#     model = treeview.get_model()
#     itr = model.get_iter_first()
#     while itr and not model[itr][col] == item:
#         itr = model.iter_next(itr)
# 
#     if not itr:
#         # item not found, cannot be selected
#         return None
# 
#     # otherwise select the item and scroll to it
#     selection = treeview.get_selection()
#     selection.select_iter(itr)
#     path = model.get_path(itr)
# 
#     # row_align=0.5 tells GTK to move the cell to the middle of the
#     # treeview viewport (0.0 should align it with the top, 1.0 with bottom)
#     # If the cell is the uppermost one, it should align it with the top
#     # of the viewport.
#     #
#     # Unfortunately, this does not work as expected due to a bug in GTK.
#     # (see rhbz#970048)
#     treeview.scroll_to_cell(path, use_align=True, row_align=0.5)
# 
#     return itr


# Path: pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
from gi.repository import Gtk, Pango
from pyanaconda import localization
from pyanaconda.iutil import strip_accents
from pyanaconda.ui.gui.utils import set_treeview_selection

    def _add_language(self, store, native, english, lang):
        """Override this method with a valid implementation"""

        raise NotImplementedError()

    def _add_locale(self, store, native, locale):
        """Override this method with a valid implementation"""

        raise NotImplementedError()

    def _select_locale(self, locale):
        """
        Try to select the given locale in the language and locale
        treeviews. This method tries to find the best match for the given
        locale.

        :return: a pair of selected iterators (language and locale)
        :rtype: a pair of GtkTreeIter or None objects

        """

        # get lang and select it
        parts = localization.parse_langcode(locale)
        if "language" not in parts:
            # invalid locale, cannot select
            return (None, None)

        lang_itr = set_treeview_selection(self._langView, parts["language"], col=2)

        # find matches and use the one with the highest rank

        locales = localization.get_language_locales(locale)