diff options
Diffstat (limited to 'Lib/lib-old/addpack.py')
| -rw-r--r-- | Lib/lib-old/addpack.py | 56 | 
1 files changed, 28 insertions, 28 deletions
diff --git a/Lib/lib-old/addpack.py b/Lib/lib-old/addpack.py index 3d09236ba9..2fb2601096 100644 --- a/Lib/lib-old/addpack.py +++ b/Lib/lib-old/addpack.py @@ -33,35 +33,35 @@  #  # If no directory is found, ImportError is raised. -_packs = {}				# {pack: [pathname, ...], ...} +_packs = {}                             # {pack: [pathname, ...], ...}  def addpack(pack, *locations): -	import os -	if os.path.isabs(pack): -		base = os.path.basename(pack) -	else: -		base = pack -	if _packs.has_key(base): -		return -	import sys -	path = [] -	for loc in _flatten(locations) + sys.path: -		fn = os.path.join(loc, base) -		if fn not in path and os.path.isdir(fn): -			path.append(fn) -	if pack != base and pack not in path and os.path.isdir(pack): -		path.append(pack) -	if not path: raise ImportError, 'package ' + pack + ' not found' -	_packs[base] = path -	for fn in path: -		if fn not in sys.path: -			sys.path.append(fn) +    import os +    if os.path.isabs(pack): +        base = os.path.basename(pack) +    else: +        base = pack +    if _packs.has_key(base): +        return +    import sys +    path = [] +    for loc in _flatten(locations) + sys.path: +        fn = os.path.join(loc, base) +        if fn not in path and os.path.isdir(fn): +            path.append(fn) +    if pack != base and pack not in path and os.path.isdir(pack): +        path.append(pack) +    if not path: raise ImportError, 'package ' + pack + ' not found' +    _packs[base] = path +    for fn in path: +        if fn not in sys.path: +            sys.path.append(fn)  def _flatten(locations): -	locs = [] -	for loc in locations: -		if type(loc) == type(''): -			locs.append(loc) -		else: -			locs = locs + _flatten(loc) -	return locs +    locs = [] +    for loc in locations: +        if type(loc) == type(''): +            locs.append(loc) +        else: +            locs = locs + _flatten(loc) +    return locs  | 
