def main()

in Chef_Processors/ChefAttributeHash.py [0:0]


    def main(self):
        att_prefix = "default['%s']['%s']['%s']" % (
            self.env["attribute_category"],
            self.env["attribute_prefix"],
            self.env["attribute"],
        )
        self.env["chef_block"] = att_prefix + " = {\n"
        for value in sorted(self.env["value"].keys()):
            self.env["chef_block"] += "\t%s => %s,\n" % (
                value,
                self.env["value"][value],
            )
        self.env["chef_block"] += "}"
        # Remove the trailing comma on the last item
        self.env["chef_block"] = self.env["chef_block"].replace(",\n}", "\n}")
        if self.env.get("in_array"):
            # if this hash is in a list of hashes, add a comma at the end
            self.env["chef_block"] += ","
        self.env["chef_block"] += "\n"
        self.output("Chef block: %s" % self.env["chef_block"])
        self.env["attribute_variable"] = att_prefix.replace("default", "node")