diff options
Diffstat (limited to 'src/engine/SCons/SConsign.py')
-rw-r--r-- | src/engine/SCons/SConsign.py | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 6fb018b..9d2f69e 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -5,7 +5,7 @@ Writing and reading information to the .sconsign file or files. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -27,17 +27,21 @@ Writing and reading information to the .sconsign file or files. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/SConsign.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +from __future__ import print_function + +__revision__ = "src/engine/SCons/SConsign.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.compat import os -# compat layer imports "cPickle" for us if it's available. import pickle import SCons.dblite import SCons.Warnings +from SCons.compat import PICKLE_PROTOCOL + + def corrupt_dblite_warning(filename): SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%filename) @@ -45,7 +49,7 @@ def corrupt_dblite_warning(filename): SCons.dblite.ignore_corrupt_dbfiles = 1 SCons.dblite.corruption_warning = corrupt_dblite_warning -#XXX Get rid of the global array so this becomes re-entrant. +# XXX Get rid of the global array so this becomes re-entrant. sig_files = [] # Info for the database SConsign implementation (now the default): @@ -59,6 +63,7 @@ DB_Module = SCons.dblite DB_Name = ".sconsign" DB_sync_list = [] + def Get_DataBase(dir): global DataBase, DB_Module, DB_Name top = dir.fs.Top @@ -84,9 +89,10 @@ def Get_DataBase(dir): DB_sync_list.append(db) return db, "c" except TypeError: - print "DataBase =", DataBase + print("DataBase =", DataBase) raise + def Reset(): """Reset global state. Used by unit tests that end up using SConsign multiple times to get a clean slate for each test.""" @@ -96,6 +102,7 @@ def Reset(): normcase = os.path.normcase + def write(): global sig_files for sig_file in sig_files: @@ -114,6 +121,7 @@ def write(): else: closemethod() + class SConsignEntry(object): """ Wrapper class for the generic entry in a .sconsign file. @@ -124,16 +132,16 @@ class SConsignEntry(object): """ __slots__ = ("binfo", "ninfo", "__weakref__") current_version_id = 2 - + def __init__(self): # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. #_version_id = self.current_version_id pass - + def convert_to_sconsign(self): self.binfo.convert_to_sconsign() - + def convert_from_sconsign(self, dir, name): self.binfo.convert_from_sconsign(dir, name) @@ -155,7 +163,8 @@ class SConsignEntry(object): for key, value in state.items(): if key not in ('_version_id','__weakref__'): setattr(self, key, value) - + + class Base(object): """ This is the controlling class for the signatures for the collection of @@ -210,6 +219,7 @@ class Base(object): self.entries[key] = entry self.to_be_merged = {} + class DB(Base): """ A Base subclass that reads and writes signature information @@ -239,7 +249,7 @@ class DB(Base): raise TypeError except KeyboardInterrupt: raise - except Exception, e: + except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.get_tpath(), e)) for key, entry in self.entries.items(): @@ -271,7 +281,7 @@ class DB(Base): path = normcase(self.dir.get_internal_path()) for key, entry in self.entries.items(): entry.convert_to_sconsign() - db[path] = pickle.dumps(self.entries, 1) + db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) if sync: try: @@ -282,6 +292,7 @@ class DB(Base): else: syncmethod() + class Dir(Base): def __init__(self, fp=None, dir=None): """ @@ -301,6 +312,7 @@ class Dir(Base): for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) + class DirFile(Dir): """ Encapsulates reading and writing a per-directory .sconsign file. @@ -359,12 +371,12 @@ class DirFile(Dir): return for key, entry in self.entries.items(): entry.convert_to_sconsign() - pickle.dump(self.entries, file, 1) + pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() if fname != self.sconsign: try: mode = os.stat(self.sconsign)[0] - os.chmod(self.sconsign, 0666) + os.chmod(self.sconsign, 0o666) os.unlink(self.sconsign) except (IOError, OSError): # Try to carry on in the face of either OSError @@ -391,6 +403,7 @@ class DirFile(Dir): ForDirectory = DB + def File(name, dbm_module=None): """ Arrange for all signatures to be stored in a global .sconsign.db* |