diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-09-28 12:19:30 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-09-28 12:19:30 +0200 |
commit | 7c6dd0eee627772485f8b06470ac84adc0f077f6 (patch) | |
tree | 69a28021c01029c221f78be31c4cb0335922ebfe /src/engine/SCons/SConsign.py | |
parent | 6be31f5d140b81227911cabfc61d3802c76c1b61 (diff) | |
parent | baee03c569c91b745a1e025660b19a718db16e7d (diff) |
Updated version 3.0.0 from 'upstream/3.0.0'
with Debian dir 147caafe8506326dfd094432b42ae32c21ed284e
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* |