def convert_deps_from_pip(dep):
    '"Converts a pip-formatted dependency to a Pipfile-formatted one.'
    dependency = {}
    req = get_requirement(dep)
    extras = {'extras': req.extras}
    if ((req.uri or req.path or is_installable_file(req.name)) and (not req.vcs)):
        if ((not req.uri) and (not req.path)):
            req.path = os.path.abspath(req.name)
        hashable_path = (req.uri if req.uri else req.path)
        if (not req.name):
            req.name = hashlib.sha256(hashable_path.encode('utf-8')).hexdigest()
            req.name = req.name[(len(req.name) - 7):]
        if req.uri:
            dependency[req.name] = {'file': hashable_path}
        else:
            dependency[req.name] = {'path': hashable_path}
        if req.extras:
            dependency[req.name].update(extras)
        if req.editable:
            dependency[req.name].update({'editable': True})
    elif req.vcs:
        if (req.name is None):
            raise ValueError('pipenv requires an #egg fragment for version controlled dependencies. Please install remote dependency in the form {0}#egg=<package-name>.'.format(req.uri))
        if req.uri.startswith('{0}+'.format(req.vcs)):
            req.uri = req.uri[(len(req.vcs) + 1):]
        dependency.setdefault(req.name, {}).update({req.vcs: req.uri})
        if req.editable:
            dependency[req.name].update({'editable': True})
        if req.subdirectory:
            dependency[req.name].update({'subdirectory': req.subdirectory})
        if req.revision:
            dependency[req.name].update({'ref': req.revision})
        if req.extras:
            dependency[req.name].update({'extras': req.extras})
    elif (req.extras or req.specs or hasattr(req, 'markers')):
        specs = None
        if req.specs:
            r = multi_split(dep, '!=<>~')
            specs = dep[len(r[0]):]
            dependency[req.name] = specs
        if req.extras:
            dependency[req.name] = extras
            if specs:
                dependency[req.name].update({'version': specs})
        if hasattr(req, 'markers'):
            if isinstance(dependency[req.name], six.string_types):
                dependency[req.name] = {'version': specs}
            dependency[req.name].update({'markers': req.markers})
    else:
        dependency[dep] = '*'
    if (len(dependency) > 1):
        for key in dependency.copy():
            if (not hasattr(dependency[key], 'keys')):
                del dependency[key]
    return dependency
"Converts a pip-formatted dependency to a Pipfile-formatted one.
def convert_deps_from_pip(dep):
    
    dependency = {}
    req = get_requirement(dep)
    extras = {'extras': req.extras}
    if ((req.uri or req.path or is_installable_file(req.name)) and (not req.vcs)):
        if ((not req.uri) and (not req.path)):
            req.path = os.path.abspath(req.name)
        hashable_path = (req.uri if req.uri else req.path)
        if (not req.name):
            req.name = hashlib.sha256(hashable_path.encode('utf-8')).hexdigest()
            req.name = req.name[(len(req.name) - 7):]
        if req.uri:
            dependency[req.name] = {'file': hashable_path}
        else:
            dependency[req.name] = {'path': hashable_path}
        if req.extras:
            dependency[req.name].update(extras)
        if req.editable:
            dependency[req.name].update({'editable': True})
    elif req.vcs:
        if (req.name is None):
            raise ValueError('pipenv requires an #egg fragment for version controlled dependencies. Please install remote dependency in the form {0}#egg=<package-name>.'.format(req.uri))
        if req.uri.startswith('{0}+'.format(req.vcs)):
            req.uri = req.uri[(len(req.vcs) + 1):]
        dependency.setdefault(req.name, {}).update({req.vcs: req.uri})
        if req.editable:
            dependency[req.name].update({'editable': True})
        if req.subdirectory:
            dependency[req.name].update({'subdirectory': req.subdirectory})
        if req.revision:
            dependency[req.name].update({'ref': req.revision})
        if req.extras:
            dependency[req.name].update({'extras': req.extras})
    elif (req.extras or req.specs or hasattr(req, 'markers')):
        specs = None
        if req.specs:
            r = multi_split(dep, '!=<>~')
            specs = dep[len(r[0]):]
            dependency[req.name] = specs
        if req.extras:
            dependency[req.name] = extras
            if specs:
                dependency[req.name].update({'version': specs})
        if hasattr(req, 'markers'):
            if isinstance(dependency[req.name], six.string_types):
                dependency[req.name] = {'version': specs}
            dependency[req.name].update({'markers': req.markers})
    else:
        dependency[dep] = '*'
    if (len(dependency) > 1):
        for key in dependency.copy():
            if (not hasattr(dependency[key], 'keys')):
                del dependency[key]
    return dependency