| 1 |
################################################################################ |
|---|
| 2 |
# Copyright (C) 2006 Travis Shirk <travis@pobox.com> |
|---|
| 3 |
# |
|---|
| 4 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 5 |
# it under the terms of the GNU General Public License as published by |
|---|
| 6 |
# the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 |
# (at your option) any later version. |
|---|
| 8 |
# |
|---|
| 9 |
# This program is distributed in the hope that it will be useful, |
|---|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
# GNU General Public License for more details. |
|---|
| 13 |
# |
|---|
| 14 |
# You should have received a copy of the GNU General Public License |
|---|
| 15 |
# along with this program; if not, write to the Free Software |
|---|
| 16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 |
# |
|---|
| 18 |
# $Id$ |
|---|
| 19 |
################################################################################ |
|---|
| 20 |
import gnomevfs |
|---|
| 21 |
|
|---|
| 22 |
# URI helpers and gnomevfs insulation |
|---|
| 23 |
|
|---|
| 24 |
class CddaURI(object): |
|---|
| 25 |
'''This is here because gnomevfs.URI is not extensible and does not like |
|---|
| 26 |
cdda:// schemes.''' |
|---|
| 27 |
def __init__(self, track_num): |
|---|
| 28 |
self.scheme = 'cdda' |
|---|
| 29 |
self.path = '%d' % track_num |
|---|
| 30 |
self.uri = '%s://%s' % (self.scheme, self.path) |
|---|
| 31 |
def __str__(self): |
|---|
| 32 |
return self.uri |
|---|
| 33 |
|
|---|
| 34 |
def is_uri(uri): |
|---|
| 35 |
return isinstance(uri, gnomevfs.URI) |
|---|
| 36 |
|
|---|
| 37 |
def make_uri(uri): |
|---|
| 38 |
if is_uri(uri): |
|---|
| 39 |
return uri.copy() |
|---|
| 40 |
else: |
|---|
| 41 |
return gnomevfs.URI(uri) |
|---|
| 42 |
|
|---|
| 43 |
def unescape(uri): |
|---|
| 44 |
return gnomevfs.unescape_string_for_display(str(uri)) |
|---|
| 45 |
|
|---|
| 46 |
def escape_path(path): |
|---|
| 47 |
return gnomevfs.escape_path_string(path) |
|---|
| 48 |
def escape_host_path(host_path): |
|---|
| 49 |
return gnomevfs.escape_host_and_path_string(host_path) |
|---|
| 50 |
def escape_slashes(s): |
|---|
| 51 |
return gnomevfs.escape_slashes(s) |
|---|
| 52 |
|
|---|
| 53 |
def uri_to_filesys_path(uri): |
|---|
| 54 |
return unescape(uri.path) |
|---|