示例#1
0
文件: manifest.py 项目: fdammeke/pulp
 def write(self):
     """
     Write the manifest to a json encoded file at the specified path.
     :raise IOError: on I/O errors.
     :raise ValueError: on json encoding errors
     """
     state = dict(
         id=self.id,
         version=self.version,
         units=self.units,
         publishing_details=self.publishing_details)
     with open(self.path, 'w+') as fp:
         json.dump(state, fp, indent=2)
示例#2
0
 def write(self):
     """
     Write the manifest to a json encoded file at the specified path.
     :raise IOError: on I/O errors.
     :raise ValueError: on json encoding errors
     """
     state = {
         ID: self.id,
         VERSION: self.version,
         UNITS: self.units,
         PUBLISHING_DETAILS: self.publishing_details
     }
     with open(self.path, 'w+') as fp:
         json.dump(state, fp, indent=2)
示例#3
0
 def write(self):
     """
     Write the manifest to a json encoded file at the specified path.
     :raise IOError: on I/O errors.
     :raise ValueError: on json encoding errors
     """
     state = {
         ID: self.id,
         VERSION: self.version,
         UNITS: self.units,
         PUBLISHING_DETAILS: self.publishing_details
     }
     with open(self.path, 'w+') as fp:
         json.dump(state, fp, indent=2)
示例#4
0
def migrate(path):
    """
    Migrate to latest version.
    :param path: The path to a stored manifest.
    :type: path: str
    """
    with open(path) as fp:
        manifest = json.load(fp)
    version_in = manifest[VERSION]
    for version in range(version_in, _manifest.MANIFEST_VERSION):
        migration = MIGRATIONS[version]
        manifest = migration(manifest)
        manifest[VERSION] = version + 1
    if version_in < manifest[VERSION]:
        with open(path, 'w+') as fp:
            json.dump(manifest, fp)