def create_skeleton(self): """ Create the role's directory and file structure. """ utils.string_to_file(os.path.join(self.output_path, "VERSION"), "master\n") for folder in c.ANSIBLE_FOLDERS: create_folder_path = os.path.join(self.output_path, folder) utils.mkdir_p(create_folder_path) mainyml_template = default_mainyml_template.replace( "%role_name", self.role_name) mainyml_template = mainyml_template.replace( "%values", folder) out_path = os.path.join(create_folder_path, "main.yml") if folder not in ("templates", "meta", "tests", "files"): utils.string_to_file(out_path, mainyml_template) if folder == "meta": utils.create_meta_main(out_path, self.config, self.role_name, self.options.galaxy_categories)
def create_skeleton(self): """ Create the role's directory and file structure. """ utils.string_to_file(os.path.join(self.output_path, "VERSION"), "master\n") for folder in c.ANSIBLE_FOLDERS: create_folder_path = os.path.join(self.output_path, folder) utils.mkdir_p(create_folder_path) mainyml_template = default_mainyml_template.replace( "%role_name", self.role_name) mainyml_template = mainyml_template.replace("%values", folder) out_path = os.path.join(create_folder_path, "main.yml") if folder not in ("templates", "meta", "tests", "files"): utils.string_to_file(out_path, mainyml_template) if folder == "meta": utils.create_meta_main(out_path, self.config, self.role_name, self.options.galaxy_categories) ag_path = os.path.join(create_folder_path, "ansigenome.yml") if not os.path.exists(ag_path): ag_meta_file = c.DEFAULT_AG_FILE ag_meta_file = meta_file.replace("%role_name", self.role_name) utils.string_to_file(self.paths['ansigenome'], ag_meta_file)
def make_or_augment_meta(self, role): """ Create or augment a meta file. """ if not os.path.exists(self.paths["meta"]): utils.create_meta_main(self.paths["meta"], self.config, role, "") self.report["state"]["ok_role"] += 1 self.report["roles"][role]["state"] = "ok" if not os.path.exists(self.paths["ansigenome"]): ag_meta_file = c.DEFAULT_AG_FILE ag_meta_file = meta_file.replace("%role_name", role) utils.string_to_file(self.paths['ansigenome'], ag_meta_file) # swap values in place to use the config values swaps = [ ("author", self.config["author_name"]), ("company", self.config["author_company"]), ("license", self.config["license_type"]), ] (new_meta, _) = utils.swap_yaml_string(self.paths["meta"], swaps) # normalize the --- at the top of the file by removing it first new_meta = new_meta.replace("---", "") new_meta = new_meta.lstrip() # augment missing main keys augments = [ ("ansigenome_info", "{}"), ("galaxy_info", "{}"), ("dependencies", "[]"), ] new_meta = self.augment_main_keys(augments, new_meta) # re-attach the --- new_meta = "---\n\n" + new_meta travis_path = os.path.join(self.paths["role"], ".travis.yml") if os.path.exists(travis_path): new_meta = new_meta.replace("travis: False", "travis: True") utils.string_to_file(self.paths["meta"], new_meta)
def make_or_augment_meta(self, role): """ Create or augment a meta file. """ if not os.path.exists(self.paths["meta"]): utils.create_meta_main(self.paths["meta"], self.config, role, "") self.report["state"]["ok_role"] += 1 self.report["roles"][role]["state"] = "ok" # swap values in place to use the config values swaps = [ ("author", self.config["author_name"]), ("company", self.config["author_company"]), ("license", self.config["license_type"]), ] (new_meta, _) = utils.swap_yaml_string(self.paths["meta"], swaps) # normalize the --- at the top of the file by removing it first new_meta = new_meta.replace("---", "") new_meta = new_meta.lstrip() # augment missing main keys augments = [ ("ansigenome_info", "{}"), ("galaxy_info", "{}"), ("dependencies", "[]"), ] new_meta = self.augment_main_keys(augments, new_meta) # re-attach the --- new_meta = "---\n\n" + new_meta travis_path = os.path.join(self.paths["role"], ".travis.yml") if os.path.exists(travis_path): new_meta = new_meta.replace("travis: False", "travis: True") utils.string_to_file(self.paths["meta"], new_meta)