def entry_point(): """ Entry point that pulp platform uses to load the importer. :return: importer class and its configuration :rtype: Importer, dict """ with open(CONFIGURATION_PATH) as fp: return NodesHttpImporter, json.load(fp)
def entry_point(): """ Entry point that pulp platform uses to load the distributor. :return: distributor class and its configuration. :rtype: Distributor, dict """ with open(CONFIGURATION_PATH) as fp: return NodesHttpDistributor, json.load(fp)
def read(self): """ Read the manifest file at the specified path. The manifest is updated using the contents of the read json document. :raise IOError: on I/O errors. :raise ValueError: on json decoding errors """ with open(self.path) as fp: d = json.load(fp) self.__dict__.update(d)
def read(self, migration=None): """ Read the manifest file at the specified path. The manifest is updated using the contents of the read json document. :param migration: Migration function used to migrate the document. :type migration: callable :raise IOError: on I/O errors. :raise ValueError: on json decoding errors """ if migration: migration(self.path) with open(self.path) as fp: d = json.load(fp) self.__dict__.update(d)
def read(self, path=None): """ Read the manifest file at the specified path. The manifest is updated using the contents of the read json document. :param path: An optional path to the manifest. :type path: str :raise IOError: on I/O errors. :raise ValueError: on json decoding errors """ with open(path or self.path) as fp: d = json.load(fp) self.id = d.get(ID) self.version = d.get(VERSION, 0) self.units = d.get(UNITS, {UNITS_PATH: None, UNITS_TOTAL: 0, UNITS_SIZE: 0}) self.publishing_details = d.get(PUBLISHING_DETAILS, {})
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)
def read(self, path=None): """ Read the manifest file at the specified path. The manifest is updated using the contents of the read json document. :param path: An optional path to the manifest. :type path: str :raise IOError: on I/O errors. :raise ValueError: on json decoding errors """ with open(path or self.path) as fp: d = json.load(fp) self.id = d.get(ID) self.version = d.get(VERSION, 0) self.units = d.get(UNITS, { UNITS_PATH: None, UNITS_TOTAL: 0, UNITS_SIZE: 0 }) self.publishing_details = d.get(PUBLISHING_DETAILS, {})