mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Some cleanup -- don't use splitfields/joinfields, standardize
indentation (tabs only), rationalize some code in urljoin...
This commit is contained in:
parent
3bb1edb328
commit
a25d7ddbf0
1 changed files with 16 additions and 18 deletions
|
@ -6,7 +6,7 @@ UC Irvine, June 1995.
|
||||||
|
|
||||||
# Standard/builtin Python modules
|
# Standard/builtin Python modules
|
||||||
import string
|
import string
|
||||||
from string import joinfields, splitfields, rfind
|
from string import join, split, rfind
|
||||||
|
|
||||||
# A classification of schemes ('' means apply by default)
|
# A classification of schemes ('' means apply by default)
|
||||||
uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'wais', 'file',
|
uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'wais', 'file',
|
||||||
|
@ -151,10 +151,8 @@ def urljoin(base, url, allow_fragments = 1):
|
||||||
if not path:
|
if not path:
|
||||||
return urlunparse((scheme, netloc, bpath,
|
return urlunparse((scheme, netloc, bpath,
|
||||||
params, query or bquery, fragment))
|
params, query or bquery, fragment))
|
||||||
i = rfind(bpath, '/')
|
segments = split(bpath, '/')[:-1] + split(path, '/')
|
||||||
if i >= 0:
|
# XXX The stuff below is bogus in various ways...
|
||||||
path = bpath[:i] + '/' + path
|
|
||||||
segments = splitfields(path, '/')
|
|
||||||
if segments[-1] == '.':
|
if segments[-1] == '.':
|
||||||
segments[-1] = ''
|
segments[-1] = ''
|
||||||
while '.' in segments:
|
while '.' in segments:
|
||||||
|
@ -173,7 +171,7 @@ def urljoin(base, url, allow_fragments = 1):
|
||||||
segments[-1] = ''
|
segments[-1] = ''
|
||||||
elif len(segments) >= 2 and segments[-1] == '..':
|
elif len(segments) >= 2 and segments[-1] == '..':
|
||||||
segments[-2:] = ['']
|
segments[-2:] = ['']
|
||||||
return urlunparse((scheme, netloc, joinfields(segments, '/'),
|
return urlunparse((scheme, netloc, join(segments, '/'),
|
||||||
params, query, fragment))
|
params, query, fragment))
|
||||||
|
|
||||||
def urldefrag(url):
|
def urldefrag(url):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue