home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 April / com_0405_1.iso / opensource / BTpp-0.5.4-bin.exe / $INSTDIR / BT++.exe / nturl2path.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-04-19  |  1.5 KB  |  55 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.2)
  3.  
  4.  
  5. def url2pathname(url):
  6.     import string
  7.     import urllib
  8.     if not ('|' in url):
  9.         if url[:4] == '////':
  10.             url = url[2:]
  11.         
  12.         components = url.split('/')
  13.         return urllib.unquote('\\'.join(components))
  14.     
  15.     comp = url.split('|')
  16.     if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
  17.         error = 'Bad URL: ' + url
  18.         raise IOError, error
  19.     
  20.     drive = comp[0][-1].upper()
  21.     components = comp[1].split('/')
  22.     path = drive + ':'
  23.     for comp in components:
  24.         if comp:
  25.             path = path + '\\' + urllib.unquote(comp)
  26.         
  27.     
  28.     return path
  29.  
  30.  
  31. def pathname2url(p):
  32.     import urllib
  33.     if not (':' in p):
  34.         if p[:2] == '\\\\':
  35.             p = '\\\\' + p
  36.         
  37.         components = p.split('\\')
  38.         return urllib.quote('/'.join(components))
  39.     
  40.     comp = p.split(':')
  41.     if len(comp) != 2 or len(comp[0]) > 1:
  42.         error = 'Bad path: ' + p
  43.         raise IOError, error
  44.     
  45.     drive = urllib.quote(comp[0].upper())
  46.     components = comp[1].split('\\')
  47.     path = '///' + drive + '|'
  48.     for comp in components:
  49.         if comp:
  50.             path = path + '/' + urllib.quote(comp)
  51.         
  52.     
  53.     return path
  54.  
  55.