mirror of
https://github.com/python/cpython.git
synced 2025-10-28 20:25:04 +00:00
Whitespace normalization, via reindent.py.
This commit is contained in:
parent
e6ddc8b20b
commit
182b5aca27
453 changed files with 31318 additions and 31452 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue