Exemple #1
0
    def gather_meta(self):
        """
        Return the meta file.
        """
        if not os.path.exists(self.paths["meta"]):
            self.dependencies = []
            return ""

        meta_dict = utils.yaml_load(self.paths["meta"])

        # gather the dependencies
        if meta_dict and "dependencies" in meta_dict:
            # create a simple list of each role that is a dependency
            dep_list = []

            for dependency in meta_dict["dependencies"]:
                if type(dependency) is dict:
                    dep_list.append(dependency["role"])
                else:
                    dep_list.append(dependency)

            # unique set of dependencies
            meta_dict["dependencies"] = list(set(dep_list))

            self.dependencies = meta_dict["dependencies"]
        else:
            self.dependencies = []

        return utils.file_to_string(self.paths["meta"])
Exemple #2
0
    def write_meta(self, role):
        """
        Write out a new meta file.
        """
        meta_file = utils.file_to_string(self.paths["meta"])

        self.update_gen_report(role, "meta", meta_file)
Exemple #3
0
    def write_meta(self, role):
        """
        Write out a new meta file.
        """
        meta_file = utils.file_to_string(self.paths["meta"])

        self.update_gen_report(role, "meta", meta_file)
Exemple #4
0
    def gather_meta(self):
        """
        Return the meta file.
        """
        if not os.path.exists(self.paths["meta"]):
            return ""

        meta_dict = utils.yaml_load(self.paths["meta"])

        # gather the dependencies
        if meta_dict and "dependencies" in meta_dict:
            # create a simple list of each role that is a dependency
            dep_list = []

            for dependency in meta_dict["dependencies"]:
                if type(dependency) is dict:
                    dep_list.append(dependency["role"])
                else:
                    dep_list.append(dependency)

            # unique set of dependencies
            meta_dict["dependencies"] = list(set(dep_list))

            self.dependencies = meta_dict["dependencies"]
        else:
            self.dependencies = []

        return utils.file_to_string(self.paths["meta"])
Exemple #5
0
    def gather_readme(self):
        """
        Return the readme file.
        """
        if not os.path.exists(self.paths["readme"]):
            return ""

        return utils.file_to_string(self.paths["readme"])
Exemple #6
0
    def gather_readme(self):
        """
        Return the readme file.
        """
        if not os.path.exists(self.paths["readme"]):
            return ""

        return utils.file_to_string(self.paths["readme"])
Exemple #7
0
 def load_access_token(klass):
     if os.path.exists("access_token.txt"):
         return utils.file_to_string("access_token.txt")
     else:
         # Generate and cache the token
         # TODO: the token expires after a year
         token = klass._generate_access_token()
         with open("access_token.txt", "w") as file_:
             file_.write(token)
         return token
Exemple #8
0
    def gather_facts_list(self, file):
        """
        Return a list of facts.
        """
        facts = []

        contents = utils.file_to_string(os.path.join(self.paths["role"], file))
        contents = re.sub(r"\s+", "", contents)
        matches = self.regex_facts.findall(contents)

        for match in matches:
            facts.append(match.split(":")[1])

        return facts
Exemple #9
0
    def gather_facts_list(self, file):
        """
        Return a list of facts.
        """
        facts = []

        contents = utils.file_to_string(os.path.join(self.paths["role"],
                                        file))
        contents = re.sub(r"\s+", "", contents)
        matches = self.regex_facts.findall(contents)

        for match in matches:
            facts.append(match.split(":")[1])

        return facts