37 from urllib.request
import urlopen
38 from urllib.error
import URLError
40 from urllib2
import urlopen
41 from urllib2
import URLError
43 PACKAGE_PREFIX =
'package://'
50 _rospack = rospkg.RosPack()
56 if url.find(PACKAGE_PREFIX) == 0:
57 mod_url = url[len(PACKAGE_PREFIX):]
58 pos = mod_url.find(
'/')
60 raise Exception(
"Could not parse package:// format into file:// format for " + url)
62 package = mod_url[0:pos]
63 mod_url = mod_url[pos:]
70 mod_url = protocol + package_path + mod_url;
76 return urlopen(filename).read()
78 raise Exception(
"Invalid URL: {}".format(filename))