# Path: pyp2rpm/dependency_convert.py
# def convert_requirement(parsed_req, use_rich_deps=True):
#     if not use_rich_deps:
#         return legacy_convert_requirement(parsed_req)
#     reqs = []
#     for spec in parsed_req.specs:
#         reqs.append(convert(parsed_req.project_name, spec[0], spec[1]))
#     if len(reqs) == 0:
#         return [['Requires', parsed_req.project_name, '{name}']]
#     if len(reqs) == 1:
#         return [['Requires', parsed_req.project_name, reqs[0]]]
#     reqs.sort(reverse=True)
#     return [['Requires', parsed_req.project_name,
#              '({})'.format(' with '.join(reqs))]]


import logging
import re
from pkg_resources import Requirement
from pyp2rpm.dependency_convert import convert_requirement



logger = logging.getLogger(__name__)


def dependency_to_rpm(dep, runtime, use_rich_deps=True):
    """Converts a dependency got by pkg_resources.Requirement.parse()
    to RPM format.
    Args:
        dep - a dependency retrieved by pkg_resources.Requirement.parse()
        runtime - whether the returned dependency should be runtime (True)
        or build time (False)
    Returns:
        List of semi-SPECFILE dependencies (package names are not properly
        converted yet).
        For example: [['Requires', 'jinja2', '{name}'],
                      ['Conflicts', 'jinja2', '{name} = 2.0.1']]
    """
    logger.debug('Dependencies provided: {0} runtime: {1}.'.format(
        dep, runtime))

# Path: pyp2rpm/dependency_convert.py
# def convert_requirement(parsed_req, use_rich_deps=True):
#     if not use_rich_deps:
#         return legacy_convert_requirement(parsed_req)
#     reqs = []
#     for spec in parsed_req.specs:
#         reqs.append(convert(parsed_req.project_name, spec[0], spec[1]))
#     if len(reqs) == 0:
#         return [['Requires', parsed_req.project_name, '{name}']]
#     if len(reqs) == 1:
#         return [['Requires', parsed_req.project_name, reqs[0]]]
#     reqs.sort(reverse=True)
#     return [['Requires', parsed_req.project_name,
#              '({})'.format(' with '.join(reqs))]]


# Path: pyp2rpm/dependency_parser.py
import logging
import re
from pkg_resources import Requirement
from pyp2rpm.dependency_convert import convert_requirement




logger = logging.getLogger(__name__)


def dependency_to_rpm(dep, runtime, use_rich_deps=True):
    """Converts a dependency got by pkg_resources.Requirement.parse()
    to RPM format.
    Args:
        dep - a dependency retrieved by pkg_resources.Requirement.parse()
        runtime - whether the returned dependency should be runtime (True)
        or build time (False)
    Returns:
        List of semi-SPECFILE dependencies (package names are not properly
        converted yet).
        For example: [['Requires', 'jinja2', '{name}'],
                      ['Conflicts', 'jinja2', '{name} = 2.0.1']]
    """
    logger.debug('Dependencies provided: {0} runtime: {1}.'.format(
        dep, runtime))

    converted = convert_requirement(dep, use_rich_deps)