summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-04-28 13:53:39 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-28 14:00:10 (GMT)
commitcf295af03fc735fbe8a01d3a72365da26c175351 (patch)
treeb1c79b757972bd29483c697ff8a45ca1eed27920 /src/engine
parentdc498d443efe453ced4bf1e329269c974427ff6b (diff)
downloadSCons-cf295af03fc735fbe8a01d3a72365da26c175351.zip
SCons-cf295af03fc735fbe8a01d3a72365da26c175351.tar.gz
SCons-cf295af03fc735fbe8a01d3a72365da26c175351.tar.bz2
[PR #3353] tweaks per review
Simplify the Py2 check for an existing-but-old cachedir by using any and a generator expression. Move an import to module scope. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/CacheDir.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index ffbb2f0..580337a 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -35,6 +35,7 @@ import sys
import SCons.Action
import SCons.Warnings
+from SCons.Util import PY3
cache_enabled = True
cache_debug = False
@@ -154,7 +155,6 @@ class CacheDir(object):
if path is None:
return
- from SCons.Util import PY3
if PY3:
self._readconfig3(path)
else:
@@ -204,9 +204,9 @@ class CacheDir(object):
"""
Python2 version of reading cache config.
- See if there's a config file in the cache directory. If there is,
+ See if there is a config file in the cache directory. If there is,
use it. If there isn't, and the directory exists and isn't empty,
- produce a warning. If the directory doesn't exist or is empty,
+ produce a warning. If the directory does not exist or is empty,
write a config file.
:param path: path to the cache directory
@@ -215,14 +215,13 @@ class CacheDir(object):
if not os.path.exists(config_file):
# A note: There is a race hazard here, if two processes start and
# attempt to create the cache directory at the same time. However,
- # python doesn't really give you the option to do exclusive file
- # creation (it doesn't even give you the option to error on opening
- # an existing file for writing...). The ordering of events here
- # as an attempt to alleviate this, on the basis that it's a pretty
- # unlikely occurence (it'd require two builds with a brand new cache
+ # Python 2.x does not give you the option to do exclusive file
+ # creation (not even the option to error on opening ad existing
+ # file for writing...). The ordering of events here as an attempt
+ # to alleviate this, on the basis that it's a pretty unlikely
+ # occurence (would require two builds with a brand new cache
# directory)
- #if os.path.isdir(path) and len(os.listdir(path)) != 0:
- if os.path.isdir(path) and len([f for f in os.listdir(path) if os.path.basename(f) != "config"]) != 0:
+ if os.path.isdir(path) and any(f != "config" for f in os.listdir(path)):
self.config['prefix_len'] = 1
# When building the project I was testing this on, the warning
# was output over 20 times. That seems excessive