def get_requirement(dep):
    from .vendor.pip9.req.req_install import _strip_extras, Wheel
    from .vendor import requirements
    'Pre-clean requirement strings passed to the requirements parser.\n\n    Ensures that we can accept both local and relative paths, file and VCS URIs,\n    remote URIs, and package names, and that we pass only valid requirement strings\n    to the requirements parser. Performs necessary modifications to requirements\n    object if the user input was a local relative path.\n\n    :param str dep: A requirement line\n    :returns: :class:`requirements.Requirement` object\n    '
    path = None
    uri = None
    cleaned_uri = None
    editable = False
    dep_link = None
    if dep.startswith('-e '):
        editable = True
        dep = dep.split(' ', 1)[1]
    if (not any((dep.startswith(uri_prefix) for uri_prefix in SCHEME_LIST))):
        marker_sep = ';'
    else:
        marker_sep = '; '
    if (marker_sep in dep):
        (dep, markers) = dep.split(marker_sep, 1)
        markers = markers.strip()
        if (not markers):
            markers = None
    else:
        markers = None
    (dep, extras) = _strip_extras(dep)
    if is_installable_file(dep):
        dep_path = Path(dep)
        dep_link = Link(dep_path.absolute().as_uri())
        if (dep_path.is_absolute() or (dep_path.as_posix() == '.')):
            path = dep_path.as_posix()
        else:
            path = get_converted_relative_path(dep)
        dep = (dep_link.egg_fragment if dep_link.egg_fragment else dep_link.url_without_fragment)
    elif is_vcs(dep):
        dep_link = Link(dep)
        uri = dep_link.url
        cleaned_uri = clean_git_uri(dep)
        dep = cleaned_uri
    if editable:
        dep = '-e {0}'.format(dep)
    req = [r for r in requirements.parse(dep)][0]
    if (req.name and (not any([req.uri, req.path]))):
        if dep_link:
            if (dep_link.scheme.startswith('file') and path and (not req.path)):
                req.path = path
                req.local_file = True
                req.uri = None
            else:
                req.uri = dep_link.url_without_fragment
    elif (req.local_file and path and (not req.vcs)):
        req.path = path
        req.uri = None
        if (dep_link and dep_link.is_wheel and (not req.name)):
            req.name = os.path.basename(Wheel(dep_link.path).name)
    elif (req.vcs and req.uri and cleaned_uri and (cleaned_uri != uri)):
        req.uri = strip_ssh_from_git_uri(req.uri)
        req.line = strip_ssh_from_git_uri(req.line)
    req.editable = editable
    if markers:
        req.markers = markers
    if extras:
        req.extras = [r for r in requirements.parse('fakepkg{0}'.format(extras))][0].extras
    return req
def get_requirement(dep):
    from .vendor.pip9.req.req_install import _strip_extras, Wheel
    from .vendor import requirements
    'Pre-clean requirement strings passed to the requirements parser.\n\n    Ensures that we can accept both local and relative paths, file and VCS URIs,\n    remote URIs, and package names, and that we pass only valid requirement strings\n    to the requirements parser. Performs necessary modifications to requirements\n    object if the user input was a local relative path.\n\n    :param str dep: A requirement line\n    :returns: :class:`requirements.Requirement` object\n    '
    path = None
    uri = None
    cleaned_uri = None
    editable = False
    dep_link = None
    if dep.startswith('-e '):
        editable = True
        dep = dep.split(' ', 1)[1]
    if (not any((dep.startswith(uri_prefix) for uri_prefix in SCHEME_LIST))):
        marker_sep = ';'
    else:
        marker_sep = '; '
    if (marker_sep in dep):
        (dep, markers) = dep.split(marker_sep, 1)
        markers = markers.strip()
        if (not markers):
            markers = None
    else:
        markers = None
    (dep, extras) = _strip_extras(dep)
    if is_installable_file(dep):
        dep_path = Path(dep)
        dep_link = Link(dep_path.absolute().as_uri())
        if (dep_path.is_absolute() or (dep_path.as_posix() == '.')):
            path = dep_path.as_posix()
        else:
            path = get_converted_relative_path(dep)
        dep = (dep_link.egg_fragment if dep_link.egg_fragment else dep_link.url_without_fragment)
    elif is_vcs(dep):
        dep_link = Link(dep)
        uri = dep_link.url
        cleaned_uri = clean_git_uri(dep)
        dep = cleaned_uri
    if editable:
        dep = '-e {0}'.format(dep)
    req = [r for r in requirements.parse(dep)][0]
    if (req.name and (not any([req.uri, req.path]))):
        if dep_link:
            if (dep_link.scheme.startswith('file') and path and (not req.path)):
                req.path = path
                req.local_file = True
                req.uri = None
            else:
                req.uri = dep_link.url_without_fragment
    elif (req.local_file and path and (not req.vcs)):
        req.path = path
        req.uri = None
        if (dep_link and dep_link.is_wheel and (not req.name)):
            req.name = os.path.basename(Wheel(dep_link.path).name)
    elif (req.vcs and req.uri and cleaned_uri and (cleaned_uri != uri)):
        req.uri = strip_ssh_from_git_uri(req.uri)
        req.line = strip_ssh_from_git_uri(req.line)
    req.editable = editable
    if markers:
        req.markers = markers
    if extras:
        req.extras = [r for r in requirements.parse('fakepkg{0}'.format(extras))][0].extras
    return req