def from_deployer_charm(cls, dcharm): c = cls() c['name'] = dcharm.name c['directory'] = dcharm.path c['testdir'] = utils.find_testdir(dcharm.path) return c
def BundleClassifier(directory, options): bundle = find_bundle_file(directory, options.bundle) if not bundle: return None return models.Bundle({ 'bundle': bundle, 'testdir': utils.find_testdir(directory), 'name': 'bundle', })
def CharmClassifier(directory, options): metadata = os.path.join(directory, "metadata.yaml") if not os.path.exists(metadata): return None testdir = utils.find_testdir(directory) metadata = yaml.safe_load(open(metadata)) return models.Charm({ 'metadata': metadata, 'testdir': testdir, 'name': metadata['name'], })
def CharmClassifier(directory, options): metadata = os.path.join(directory, "metadata.yaml") if not os.path.exists(metadata): return None lp = vcs.Launchpad() data = lp.infer_charm(directory) or {} testdir = utils.find_testdir(directory) metadata = yaml.safe_load(open(metadata)) data['metadata'] = metadata data['testdir'] = testdir if 'name' not in data: data['name'] = metadata['name'] return models.Charm(**data)
def BundleClassifier(directory, options): bundle = find_bundle_file(directory, options.bundle) if not bundle: return None result = {'bundle': bundle, 'testdir': utils.find_testdir(directory)} lp = vcs.Launchpad() data = lp.infer_bundle(directory) or {} result.update(data) if 'name' not in data: with open(bundle) as fh: metadata = yaml.safe_load(fh) # XXX: ambiguous result['name'] = metadata.keys()[0] return models.Bundle(**result)
def from_deployer_charm(cls, dcharm): """Copy charm source from the deployer cache to a new temp location so we can change the charm dir name to match the charm name (some tests rely on these matching). """ tmp_dir = tempfile.mkdtemp() charm_name = dcharm.name.split('/')[-1] # Strip off revision if there is one name_parts = charm_name.split('-') if is_int(name_parts[-1]): charm_name = '-'.join(name_parts[:-1]) charm_dir = os.path.join(tmp_dir, charm_name) shutil.copytree(dcharm.path, charm_dir, symlinks=True) atexit.register(shutil.rmtree, tmp_dir) c = cls() c['name'] = dcharm.name c['directory'] = charm_dir c['testdir'] = utils.find_testdir(charm_dir) return c
def from_deployer_charm(cls, dcharm): """Copy charm source from the deployer cache to a new temp location so we can change the charm dir name to match the charm name (some tests rely on these matching). """ tmp_dir = tempfile.mkdtemp() charm_name = dcharm.name.split("/")[-1] # Strip off revision if there is one name_parts = charm_name.split("-") if is_int(name_parts[-1]): charm_name = "-".join(name_parts[:-1]) charm_dir = os.path.join(tmp_dir, charm_name) shutil.copytree(dcharm.path, charm_dir, symlinks=True) atexit.register(shutil.rmtree, tmp_dir) c = cls() c["name"] = dcharm.name c["directory"] = charm_dir c["testdir"] = utils.find_testdir(charm_dir) return c