OLD | NEW |
1 # Copyright 2013 The Swarming Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
2 # Use of this source code is governed under the Apache License, Version 2.0 that | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
3 # can be found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utilities to work with importable python zip packages.""" | 5 """Utilities to work with importable python zip packages.""" |
6 | 6 |
7 import atexit | 7 import atexit |
8 import collections | 8 import collections |
9 import cStringIO as StringIO | 9 import cStringIO as StringIO |
10 import hashlib | 10 import hashlib |
11 import os | 11 import os |
12 import pkgutil | 12 import pkgutil |
13 import re | 13 import re |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 h = hashlib.sha1() | 336 h = hashlib.sha1() |
337 with zipfile.ZipFile(get_main_script_path(), 'r') as z: | 337 with zipfile.ZipFile(get_main_script_path(), 'r') as z: |
338 for name in sorted(z.namelist()): | 338 for name in sorted(z.namelist()): |
339 with z.open(name) as f: | 339 with z.open(name) as f: |
340 h.update(str(len(name))) | 340 h.update(str(len(name))) |
341 h.update(name) | 341 h.update(name) |
342 content = f.read() | 342 content = f.read() |
343 h.update(str(len(content))) | 343 h.update(str(len(content))) |
344 h.update(content) | 344 h.update(content) |
345 return h.hexdigest() | 345 return h.hexdigest() |
OLD | NEW |