Expand path_to_uri functionality
This commit is contained in:
parent
03a453eb64
commit
0186bd81db
@ -33,7 +33,8 @@ def get_or_create_dotdir(dotdir):
|
||||
os.mkdir(dotdir, 0755)
|
||||
return dotdir
|
||||
|
||||
def path_to_uri(path):
|
||||
def path_to_uri(*paths):
|
||||
path = os.path.join(*paths)
|
||||
return 'file://' + urllib.pathname2url(path)
|
||||
|
||||
def indent(string, places=4, linebreak='\n'):
|
||||
|
||||
@ -18,12 +18,24 @@ class PathToFileURITest(unittest.TestCase):
|
||||
result = path_to_uri('c:/WINDOWS/clock.avi')
|
||||
self.assertEqual(result, 'file:///c:/WINDOWS/clock.avi')
|
||||
|
||||
def test_folder_prefix_unix(self):
|
||||
if sys.platform != 'win32':
|
||||
return
|
||||
result = path_to_uri('c:/WINDOWS/', 'clock.avi')
|
||||
self.assertEqual(result, 'file:///c:/WINDOWS/clock.avi')
|
||||
|
||||
def test_unix_paths(self):
|
||||
if sys.platform == 'win32':
|
||||
return
|
||||
result = path_to_uri('/etc/fstab')
|
||||
self.assertEqual(result, 'file:///etc/fstab')
|
||||
|
||||
def test_folder_prefix_unix(self):
|
||||
if sys.platform == 'win32':
|
||||
return
|
||||
result = path_to_uri('/etc', 'fstab')
|
||||
self.assertEqual(result, 'file:///etc/fstab')
|
||||
|
||||
|
||||
song1_path = data_folder('song1.mp3')
|
||||
song2_path = data_folder('song2.mp3')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user