mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Improve some random tool shed code.
This commit is contained in:
@@ -58,6 +58,21 @@ NULL_CHAR = '\000'
|
||||
BINARY_CHARS = [ NULL_CHAR ]
|
||||
|
||||
|
||||
def remove_protocol_from_url( url ):
|
||||
""" Supplied URL may be null, if not ensure http:// or https://
|
||||
etc... is stripped off.
|
||||
"""
|
||||
if url is None:
|
||||
return url
|
||||
|
||||
# We have a URL
|
||||
if url.find( '://' ) > 0:
|
||||
new_url = url.split( '://' )[1]
|
||||
else:
|
||||
new_url = url
|
||||
return new_url.rstrip( '/' )
|
||||
|
||||
|
||||
def is_binary( value, binary_chars=None ):
|
||||
"""
|
||||
File is binary if it contains a null-byte by default (e.g. behavior of grep, etc.).
|
||||
|
||||
@@ -337,18 +337,7 @@ def remove_protocol_and_user_from_clone_url( repository_clone_url ):
|
||||
|
||||
def remove_protocol_from_tool_shed_url( tool_shed_url ):
|
||||
"""Return a partial Tool Shed URL, eliminating the protocol if it exists."""
|
||||
try:
|
||||
if tool_shed_url.find( '://' ) > 0:
|
||||
new_tool_shed_url = tool_shed_url.split( '://' )[1]
|
||||
else:
|
||||
new_tool_shed_url = tool_shed_url
|
||||
return new_tool_shed_url.rstrip( '/' )
|
||||
except Exception, e:
|
||||
# We receive a lot of calls here where the tool_shed_url is None. The container_util uses
|
||||
# that value when creating a header row. If the tool_shed_url is not None, we have a problem.
|
||||
if tool_shed_url is not None:
|
||||
log.exception( "Handled exception removing the protocol from Tool Shed URL %s:\n%s", str( tool_shed_url ), e )
|
||||
return tool_shed_url
|
||||
return util.remove_protocol_from_url( tool_shed_url )
|
||||
|
||||
|
||||
def tool_shed_get( app, base_url, pathspec=[], params={} ):
|
||||
|
||||
Reference in New Issue
Block a user