def create_defs(self):
     """
     Create /defs/ Node.
     """
     defs = Node("defs", self.get_super_root())
     defs.set_transient(True)
     defs.set_config("$hidden", True)
     defs.add_child(Node("profile", defs))
     self.get_super_root().add_child(defs)
class PopulationDSLink(DSLink):
    def __init__(self):
        super().__init__(Configuration("Population", responder=True))
        self.countries = Node("Countries", self.super_root)

        self.hammock = hammock.Hammock("http://api.population.io/1.0")
        countries = self.hammock.countries().GET(headers={"Content-Type": "application/json"}).json()["countries"]
        for country in countries:
            country_node = Node(country, self.countries)
            self.countries.add_child(country_node)

        self.super_root.add_child(self.countries)
Exemple #3
0
 def create_rng(self, data):
     name = data[1]["Name"]
     if self.responder.get_super_root().get("/%s" % name) is None:
         rng = Node(name, self.responder.get_super_root())
         rng.set_config("$is", "rng")
         rng.set_type("number")
         rng.set_value(0)
         self.responder.get_super_root().add_child(rng)
         delete = Node("delete", rng)
         delete.set_config("$is", "delete_rng")
         delete.set_invokable("config")
         rng.add_child(delete)
         self.rngs[name] = rng
         return [
             [
                 True
             ]
         ]
     return [
         [
             False
         ]
     ]