<s> """<STR_LIT>""" <EOL> def url2pathname ( url ) : <EOL> """<STR_LIT>""" <EOL> import string , urllib <EOL> url = url . replace ( '<STR_LIT::>' , '<STR_LIT:|>' ) <EOL> if not '<STR_LIT:|>' in url : <EOL> if url [ : <NUM_LIT:4> ] == '<STR_LIT>' : <EOL> url = url [ <NUM_LIT:2> : ] <EOL> components = url . split ( '<STR_LIT:/>' ) <EOL> return urllib . unquote ( '<STR_LIT:\\>' . join ( components ) ) <EOL> comp = url . split ( '<STR_LIT:|>' ) <EOL> if len ( comp ) != <NUM_LIT:2> or comp [ <NUM_LIT:0> ] [ - <NUM_LIT:1> ] not in string . ascii_letters : <EOL> error = '<STR_LIT>' + url <EOL> raise IOError , error <EOL> drive = comp [ <NUM_LIT:0> ] [ - <NUM_LIT:1> ] . upper ( ) <EOL> path = drive + '<STR_LIT::>' <EOL> components = comp [ <NUM_LIT:1> ] . split ( '<STR_LIT:/>' ) <EOL> for comp in components : <EOL> if comp : <EOL> path = path + '<STR_LIT:\\>' + urllib . unquote ( comp ) <EOL> if path . endswith ( '<STR_LIT::>' ) and url . endswith ( '<STR_LIT:/>' ) : <EOL> path += '<STR_LIT:\\>' <EOL> return path <EOL> def pathname2url ( p ) : <EOL> """<STR_LIT>""" <EOL> import urllib <EOL> if not '<STR_LIT::>' in p : <EOL> if p [ : <NUM_LIT:2> ] == '<STR_LIT>' : <EOL> p = '<STR_LIT>' + p <EOL> components = p . split ( '<STR_LIT:\\>' ) <EOL> return urllib . quote ( '<STR_LIT:/>' . join ( components ) ) <EOL> comp = p . split ( '<STR_LIT::>' ) <EOL> if len ( comp ) != <NUM_LIT:2> or len ( comp [ <NUM_LIT:0> ] ) > <NUM_LIT:1> : <EOL> error = '<STR_LIT>' + p <EOL> raise IOError , error <EOL> drive = urllib . quote ( comp [ <NUM_LIT:0> ] . upper ( ) ) <EOL> components = comp [ <NUM_LIT:1> ] . split ( '<STR_LIT:\\>' ) <EOL> path = '<STR_LIT>' + drive + '<STR_LIT::>' <EOL> for comp in components : <EOL> if comp : <EOL> path = path + '<STR_LIT:/>' + urllib . quote ( comp ) <EOL> return path </s>
