diff options
author | Brett Cannon <brett@python.org> | 2012-01-27 00:03:52 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-01-27 00:03:52 (GMT) |
commit | 51d14f8e565cd82a4efb6c18b7fdf29eddcca878 (patch) | |
tree | 9a146ef6ba3cdb1e1ed71cfa1b2d2fae8c406329 /Lib/importlib/_bootstrap.py | |
parent | e9cd900585d44b418b2a2235a7eec6e4b362798f (diff) | |
download | cpython-51d14f8e565cd82a4efb6c18b7fdf29eddcca878.zip cpython-51d14f8e565cd82a4efb6c18b7fdf29eddcca878.tar.gz cpython-51d14f8e565cd82a4efb6c18b7fdf29eddcca878.tar.bz2 |
Relocate importlib._case_ok to importlib._bootstrap.
This required updating the code to use posix instead of os. This is
all being done to make bootstrapping easier to removing dependencies
that are kept in importlib.__init__ and thus outside of the single
file to bootstrap from.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index e81fa9f..f0de77b 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -18,6 +18,33 @@ work. One should use importlib as the public-facing version of this module. # Bootstrap-related code ###################################################### +# TODO: when not on any of these platforms, replace _case_ok() w/ +# ``lambda x,y: True``. +CASE_OK_PLATFORMS = 'win', 'cygwin', 'darwin' + +def _case_ok(directory, check): + """Check if the directory contains something matching 'check' + case-sensitively when running on Windows or OS X. + + If running on Window or OS X and PYTHONCASEOK is a defined environment + variable then no case-sensitive check is performed. No check is done to see + if what is being checked for exists, so if the platform is not Windows or + OS X then assume the case is fine. + + """ + if (any(map(sys.platform.startswith, CASE_OK_PLATFORMS)) and + b'PYTHONCASEOK' not in _os.environ): + if not directory: + directory = '.' + if check in _os.listdir(directory): + return True + else: + return False + else: + return True + + + # TODO: Expose from marshal def _w_long(x): """Convert a 32-bit integer to little-endian. |