# Path: dnf/i18n.py
# def ucd(obj):
#     # :api, deprecated in 2.0.0, will be erased when python2 is abandoned
#     """ Like the builtin unicode() but tries to use a reasonable encoding. """
#     if dnf.pycomp.PY3:
#         if dnf.pycomp.is_py3bytes(obj):
#             return str(obj, _guess_encoding(), errors='ignore')
#         elif isinstance(obj, str):
#             return obj
#         return str(obj)
#     else:
#         if isinstance(obj, dnf.pycomp.unicode):
#             return obj
#         if hasattr(obj, '__unicode__'):
#             # see the doc for the unicode() built-in. The logic here is: if obj
#             # implements __unicode__, let it take a crack at it, but handle the
#             # situation if it fails:
#             try:
#                 return dnf.pycomp.unicode(obj)
#             except UnicodeError:
#                 pass
#         return dnf.pycomp.unicode(str(obj), _guess_encoding(), errors='ignore')


import hawkey
from hawkey import Query
from dnf.i18n import ucd
from dnf.pycomp import basestring
# Public License for more details.  You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#

from __future__ import absolute_import
from __future__ import unicode_literals




def _by_provides(sack, patterns, ignore_case=False, get_query=False):
    if isinstance(patterns, basestring):
        patterns = [patterns]

    q = sack.query()
    flags = []
    if ignore_case:
        flags.append(hawkey.ICASE)

    q.filterm(*flags, provides__glob=patterns)
    if get_query:
        return q
    return q.run()

def _per_nevra_dict(pkg_list):

# Path: dnf/i18n.py
# def ucd(obj):
#     # :api, deprecated in 2.0.0, will be erased when python2 is abandoned
#     """ Like the builtin unicode() but tries to use a reasonable encoding. """
#     if dnf.pycomp.PY3:
#         if dnf.pycomp.is_py3bytes(obj):
#             return str(obj, _guess_encoding(), errors='ignore')
#         elif isinstance(obj, str):
#             return obj
#         return str(obj)
#     else:
#         if isinstance(obj, dnf.pycomp.unicode):
#             return obj
#         if hasattr(obj, '__unicode__'):
#             # see the doc for the unicode() built-in. The logic here is: if obj
#             # implements __unicode__, let it take a crack at it, but handle the
#             # situation if it fails:
#             try:
#                 return dnf.pycomp.unicode(obj)
#             except UnicodeError:
#                 pass
#         return dnf.pycomp.unicode(str(obj), _guess_encoding(), errors='ignore')


# Path: dnf/query.py
import hawkey
from hawkey import Query
from dnf.i18n import ucd
from dnf.pycomp import basestring

# Public License for more details.  You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#

from __future__ import absolute_import
from __future__ import unicode_literals




def _by_provides(sack, patterns, ignore_case=False, get_query=False):
    if isinstance(patterns, basestring):
        patterns = [patterns]

    q = sack.query()
    flags = []
    if ignore_case:
        flags.append(hawkey.ICASE)

    q.filterm(*flags, provides__glob=patterns)
    if get_query:
        return q
    return q.run()

def _per_nevra_dict(pkg_list):

    return {ucd(pkg):pkg for pkg in pkg_list}