#NEWLINE# def replace_dependencies( package_json , kind , memo = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# 'Replace a top-level package\'s dependencies with their repository URLs.\nkind is a type of dependency, such as "dependencies" or "devDependencies" etc.' #NEWLINE# deps = package_json . get ( kind , None ) #NEWLINE# if ( deps is None ) : #NEWLINE# #INDENT# return ( package_json , memo ) #NEWLINE# #UNINDENT# for dependency in deps . keys ( ) : #NEWLINE# #INDENT# if ( dependency not in memo ) : #NEWLINE# #INDENT# package = project_info ( dependency ) #NEWLINE# if ( package is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# repo = repository_url ( package ) #NEWLINE# if ( repo is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if repo . startswith ( 'http' ) : #NEWLINE# #INDENT# repo = ( 'git+' + repo ) #NEWLINE# #UNINDENT# package_json [ kind ] [ dependency ] = repo #NEWLINE# memo [ dependency ] = repo #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# package_json [ kind ] [ dependency ] = memo [ dependency ] #NEWLINE# #UNINDENT# #UNINDENT# return ( package_json , memo )