# Path: dnf/i18n.py
# class UnicodeStream(object):
#     def __init__(self, stream, encoding):
#     def write(self, s):
#     def __getattr__(self, name):
# def _full_ucd_support(encoding):
# def _guess_encoding():
# def setup_locale():
# def setup_stdout():
# def ucd_input(ucstring):
# def ucd(obj):
# def _exact_width_char(uchar):
# def chop_str(msg, chop=None):
# def exact_width(msg):
# def fill_exact_width(msg, fill, chop=None, left=True, prefix='', suffix=''):
# def textwrap_fill(text, width=70, initial_indent='', subsequent_indent=''):
#     def _indent_at_beg(line):
# def select_short_long(width, msg_short, msg_long):
# def translation(name):
#     def ucd_wrapper(fnc):
# def pgettext(context, message):
# _, P_ = translation("dnf")
# C_ = pgettext
# 
# Path: dnf/util.py
# def _parse_specs(namespace, values):
#     """
#     Categorize :param values list into packages, groups and filenames
# 
#     :param namespace: argparse.Namespace, where specs will be stored
#     :param values: list of specs, whether packages ('foo') or groups/modules ('@bar')
#                    or filenames ('*.rmp', 'http://*', ...)
# 
#     To access packages use: specs.pkg_specs,
#     to access groups use: specs.grp_specs,
#     to access filenames use: specs.filenames
#     """
# 
#     setattr(namespace, "filenames", [])
#     setattr(namespace, "grp_specs", [])
#     setattr(namespace, "pkg_specs", [])
#     tmp_set = set()
#     for value in values:
#         if value in tmp_set:
#             continue
#         tmp_set.add(value)
#         schemes = dnf.pycomp.urlparse.urlparse(value)[0]
#         if value.endswith('.rpm'):
#             namespace.filenames.append(value)
#         elif schemes and schemes in ('http', 'ftp', 'file', 'https'):
#             namespace.filenames.append(value)
#         elif value.startswith('@'):
#             namespace.grp_specs.append(value[1:])
#         else:
#             namespace.pkg_specs.append(value)


from dnf.i18n import _
from dnf.util import _parse_specs
import argparse
import dnf.exceptions
import dnf.util
import dnf.rpm
import dnf.yum.misc
import logging
import os.path
import re
import sys
logger = logging.getLogger("dnf")


class MultilineHelpFormatter(argparse.HelpFormatter):
    def _split_lines(self, text, width):
        if '\n' in text:
            return text.splitlines()
        return super(MultilineHelpFormatter, self)._split_lines(text, width)

class OptionParser(argparse.ArgumentParser):
    """ArgumentParser like class to do things the "yum way"."""

    def __init__(self, reset_usage=True):
        super(OptionParser, self).__init__(add_help=False,
                                           formatter_class=MultilineHelpFormatter)
        self.command_positional_parser = None
        self.command_group = None
        self._add_general_options()
        if reset_usage:
            self._cmd_usage = {}      # names, summary for dnf commands, to build usage
            self._cmd_groups = set()  # cmd groups added (main, plugin)

    def error(self, msg):
        """Output an error message, and exit the program.
           This method overrides standard argparser's error
           so that error output goes to the logger.

        :param msg: the error message to output
        """
        self.print_usage()

# Path: dnf/i18n.py
# class UnicodeStream(object):
#     def __init__(self, stream, encoding):
#     def write(self, s):
#     def __getattr__(self, name):
# def _full_ucd_support(encoding):
# def _guess_encoding():
# def setup_locale():
# def setup_stdout():
# def ucd_input(ucstring):
# def ucd(obj):
# def _exact_width_char(uchar):
# def chop_str(msg, chop=None):
# def exact_width(msg):
# def fill_exact_width(msg, fill, chop=None, left=True, prefix='', suffix=''):
# def textwrap_fill(text, width=70, initial_indent='', subsequent_indent=''):
#     def _indent_at_beg(line):
# def select_short_long(width, msg_short, msg_long):
# def translation(name):
#     def ucd_wrapper(fnc):
# def pgettext(context, message):
# _, P_ = translation("dnf")
# C_ = pgettext
# 
# Path: dnf/util.py
# def _parse_specs(namespace, values):
#     """
#     Categorize :param values list into packages, groups and filenames
# 
#     :param namespace: argparse.Namespace, where specs will be stored
#     :param values: list of specs, whether packages ('foo') or groups/modules ('@bar')
#                    or filenames ('*.rmp', 'http://*', ...)
# 
#     To access packages use: specs.pkg_specs,
#     to access groups use: specs.grp_specs,
#     to access filenames use: specs.filenames
#     """
# 
#     setattr(namespace, "filenames", [])
#     setattr(namespace, "grp_specs", [])
#     setattr(namespace, "pkg_specs", [])
#     tmp_set = set()
#     for value in values:
#         if value in tmp_set:
#             continue
#         tmp_set.add(value)
#         schemes = dnf.pycomp.urlparse.urlparse(value)[0]
#         if value.endswith('.rpm'):
#             namespace.filenames.append(value)
#         elif schemes and schemes in ('http', 'ftp', 'file', 'https'):
#             namespace.filenames.append(value)
#         elif value.startswith('@'):
#             namespace.grp_specs.append(value[1:])
#         else:
#             namespace.pkg_specs.append(value)


# Path: dnf/cli/option_parser.py
from dnf.i18n import _
from dnf.util import _parse_specs
import argparse
import dnf.exceptions
import dnf.util
import dnf.rpm
import dnf.yum.misc
import logging
import os.path
import re
import sys

logger = logging.getLogger("dnf")


class MultilineHelpFormatter(argparse.HelpFormatter):
    def _split_lines(self, text, width):
        if '\n' in text:
            return text.splitlines()
        return super(MultilineHelpFormatter, self)._split_lines(text, width)

class OptionParser(argparse.ArgumentParser):
    """ArgumentParser like class to do things the "yum way"."""

    def __init__(self, reset_usage=True):
        super(OptionParser, self).__init__(add_help=False,
                                           formatter_class=MultilineHelpFormatter)
        self.command_positional_parser = None
        self.command_group = None
        self._add_general_options()
        if reset_usage:
            self._cmd_usage = {}      # names, summary for dnf commands, to build usage
            self._cmd_groups = set()  # cmd groups added (main, plugin)

    def error(self, msg):
        """Output an error message, and exit the program.
           This method overrides standard argparser's error
           so that error output goes to the logger.

        :param msg: the error message to output
        """
        self.print_usage()

        logger.critical(_("Command line error: %s"), msg)