예제 #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"])
예제 #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)
예제 #3
0
파일: scan.py 프로젝트: dr1s/ansigenome
    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)
예제 #4
0
파일: scan.py 프로젝트: dr1s/ansigenome
    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"])
예제 #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"])
예제 #6
0
파일: scan.py 프로젝트: dr1s/ansigenome
    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"])
예제 #7
0
파일: main.py 프로젝트: ahuff44/go-bot
 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
예제 #8
0
파일: scan.py 프로젝트: dr1s/ansigenome
    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
예제 #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