config/rebuild_check.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 import os
     6 import errno
     8 def mtime(path):
     9     try:
    10         return os.stat(path).st_mtime
    11     except OSError as e:
    12         if e.errno == errno.ENOENT:
    13             return -1
    14         raise
    16 def rebuild_check(args):
    17     target = args[0]
    18     deps = args[1:]
    19     t = mtime(target)
    20     if t < 0:
    21         print target
    22         return
    24     newer = []
    25     removed = []
    26     for dep in deps:
    27         deptime = mtime(dep)
    28         if deptime < 0:
    29             removed.append(dep)
    30         elif mtime(dep) > t:
    31             newer.append(dep)
    33     if newer and removed:
    34         print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
    35     elif newer:
    36         print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
    37     elif removed:
    38         print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
    39     else:
    40         print 'Rebuilding %s for an unknown reason' % target
    42 if __name__ == '__main__':
    43     import sys
    44     rebuild_check(sys.argv[1:])

mercurial