| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Understands .isolated files and can do local operations on them.""" | 5 """Understands .isolated files and can do local operations on them.""" |
| 6 | 6 |
| 7 import hashlib | 7 import hashlib |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if not chunk: | 79 if not chunk: |
| 80 break | 80 break |
| 81 digest.update(chunk) | 81 digest.update(chunk) |
| 82 return digest.hexdigest() | 82 return digest.hexdigest() |
| 83 | 83 |
| 84 | 84 |
| 85 class IsolatedFile(object): | 85 class IsolatedFile(object): |
| 86 """Represents a single parsed .isolated file.""" | 86 """Represents a single parsed .isolated file.""" |
| 87 | 87 |
| 88 def __init__(self, obj_hash, algo): | 88 def __init__(self, obj_hash, algo): |
| 89 """|obj_hash| is really the sha-1 of the file.""" | 89 """|obj_hash| is really the hash of the file.""" |
| 90 self.obj_hash = obj_hash | 90 self.obj_hash = obj_hash |
| 91 self.algo = algo | 91 self.algo = algo |
| 92 | 92 |
| 93 # Raw data. | 93 # Raw data. |
| 94 self.data = {} | 94 self.data = {} |
| 95 # A IsolatedFile instance, one per object in self.includes. | 95 # A IsolatedFile instance, one per object in self.includes. |
| 96 self.children = [] | 96 self.children = [] |
| 97 | 97 |
| 98 # Set once the .isolated file is loaded. | 98 # Set once the .isolated file is loaded. |
| 99 self._is_loaded = False | 99 self._is_loaded = False |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 data['files'] = dict( | 574 data['files'] = dict( |
| 575 (k.replace(wrong_path_sep, os.path.sep), v) | 575 (k.replace(wrong_path_sep, os.path.sep), v) |
| 576 for k, v in data['files'].iteritems()) | 576 for k, v in data['files'].iteritems()) |
| 577 for v in data['files'].itervalues(): | 577 for v in data['files'].itervalues(): |
| 578 if 'l' in v: | 578 if 'l' in v: |
| 579 v['l'] = v['l'].replace(wrong_path_sep, os.path.sep) | 579 v['l'] = v['l'].replace(wrong_path_sep, os.path.sep) |
| 580 if 'relative_cwd' in data: | 580 if 'relative_cwd' in data: |
| 581 data['relative_cwd'] = data['relative_cwd'].replace( | 581 data['relative_cwd'] = data['relative_cwd'].replace( |
| 582 wrong_path_sep, os.path.sep) | 582 wrong_path_sep, os.path.sep) |
| 583 return data | 583 return data |
| OLD | NEW |