This commit is contained in:
Kovid Goyal 2008-06-30 12:05:51 -07:00
parent 0b0346884f
commit e74166ea09

View File

@ -80,14 +80,16 @@ class Resource(object):
basedir = os.getcwd() basedir = os.getcwd()
if self.path is None: if self.path is None:
return self._href return self._href
frag = '#'+quote(self.fragment) if self.fragment else '' f = self.fragment.encode('utf-8') if isinstance(self.fragment, unicode) else self.fragment
frag = '#'+quote(f) if self.fragment else ''
if self.path == basedir: if self.path == basedir:
return ''+frag return ''+frag
try: try:
rpath = relpath(self.path, basedir) rpath = relpath(self.path, basedir)
except OSError: # On windows path and basedir could be on different drives except OSError: # On windows path and basedir could be on different drives
rpath = self.path rpath = self.path
if isinstance(rpath, unicode):
rpath = rpath.encode('utf-8')
return quote(rpath.replace(os.sep, '/'))+frag return quote(rpath.replace(os.sep, '/'))+frag
def set_basedir(self, path): def set_basedir(self, path):