| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import copy | 5 import copy |
| 6 import hashlib | 6 import hashlib |
| 7 import json | 7 import json |
| 8 import string | 8 import string |
| 9 import sys | 9 import sys |
| 10 import urllib2 | 10 import urllib2 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if error_on_unknown_keys: | 149 if error_on_unknown_keys: |
| 150 for key in self: | 150 for key in self: |
| 151 if key not in VALID_ARCHIVE_KEYS: | 151 if key not in VALID_ARCHIVE_KEYS: |
| 152 raise Error('Archive "%s" has invalid attribute "%s"' % ( | 152 raise Error('Archive "%s" has invalid attribute "%s"' % ( |
| 153 host_os, key)) | 153 host_os, key)) |
| 154 | 154 |
| 155 def UpdateVitals(self, revision): | 155 def UpdateVitals(self, revision): |
| 156 """Update the size and checksum information for this archive | 156 """Update the size and checksum information for this archive |
| 157 based on the content currently at the URL. | 157 based on the content currently at the URL. |
| 158 | 158 |
| 159 This allows the template mandifest to be maintained without | 159 This allows the template manifest to be maintained without |
| 160 the need to size and checksums to be present. | 160 the need to size and checksums to be present. |
| 161 """ | 161 """ |
| 162 template = string.Template(self['url']) | 162 template = string.Template(self['url']) |
| 163 self['url'] = template.substitute({'revision': revision}) | 163 self['url'] = template.substitute({'revision': revision}) |
| 164 from_stream = urllib2.urlopen(self['url']) | 164 from_stream = urllib2.urlopen(self['url']) |
| 165 sha1_hash, size = DownloadAndComputeHash(from_stream) | 165 sha1_hash, size = DownloadAndComputeHash(from_stream) |
| 166 self['size'] = size | 166 self['size'] = size |
| 167 self['checksum'] = { 'sha1': sha1_hash } | 167 self['checksum'] = { 'sha1': sha1_hash } |
| 168 | 168 |
| 169 def __getattr__(self, name): | 169 def __getattr__(self, name): |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 local_bundle = self.GetBundle(bundle.name) | 521 local_bundle = self.GetBundle(bundle.name) |
| 522 if not local_bundle: | 522 if not local_bundle: |
| 523 self.SetBundle(bundle) | 523 self.SetBundle(bundle) |
| 524 else: | 524 else: |
| 525 if not allow_existing: | 525 if not allow_existing: |
| 526 raise Error('cannot merge manifest bundle \'%s\', it already exists' | 526 raise Error('cannot merge manifest bundle \'%s\', it already exists' |
| 527 % bundle.name) | 527 % bundle.name) |
| 528 local_bundle.MergeWithBundle(bundle) | 528 local_bundle.MergeWithBundle(bundle) |
| 529 | 529 |
| 530 def MergeManifest(self, manifest): | 530 def MergeManifest(self, manifest): |
| 531 '''Merge another manifest into this manifest, disallowing overiding. | 531 '''Merge another manifest into this manifest, disallowing overriding. |
| 532 | 532 |
| 533 Args | 533 Args |
| 534 manifest: The manifest to merge. | 534 manifest: The manifest to merge. |
| 535 ''' | 535 ''' |
| 536 for bundle in manifest.GetBundles(): | 536 for bundle in manifest.GetBundles(): |
| 537 self.MergeBundle(bundle, allow_existing=False) | 537 self.MergeBundle(bundle, allow_existing=False) |
| 538 | 538 |
| 539 def FilterBundles(self, predicate): | 539 def FilterBundles(self, predicate): |
| 540 """Filter the list of bundles by |predicate|. | 540 """Filter the list of bundles by |predicate|. |
| 541 | 541 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return False | 590 return False |
| 591 | 591 |
| 592 return True | 592 return True |
| 593 | 593 |
| 594 def __ne__(self, other): | 594 def __ne__(self, other): |
| 595 return not (self == other) | 595 return not (self == other) |
| 596 | 596 |
| 597 def GetDataAsString(self): | 597 def GetDataAsString(self): |
| 598 """Returns the current JSON manifest object, pretty-printed""" | 598 """Returns the current JSON manifest object, pretty-printed""" |
| 599 return DictToJSON(self._manifest_data) | 599 return DictToJSON(self._manifest_data) |
| OLD | NEW |