From 3cb694ca7f4bcedf75540bc5fa7af9bbe5c8132d Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Tue, 16 May 2023 13:05:36 -0600 Subject: [PATCH] add doc strings --- buildingmotif/ingresses/base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/buildingmotif/ingresses/base.py b/buildingmotif/ingresses/base.py index 86a2afbf2..046d1c161 100644 --- a/buildingmotif/ingresses/base.py +++ b/buildingmotif/ingresses/base.py @@ -41,10 +41,19 @@ def records(self) -> List[Record]: raise NotImplementedError("Must be overridden by subclass") def dump(self, path: PathLike): + """ + Takes the contents of the records of this handler and writes them to a JSON file + + :param path: path to write output file to + :type path: PathLike + """ output_string = self.dumps() Path(path).write_text(output_string) def dumps(self) -> str: + """ + Takes the contents of the records of this handler and writes them to a string + """ records = [ {"rtype": record.rtype, "fields": record.fields} for record in self.records ] @@ -52,10 +61,16 @@ def dumps(self) -> str: @classmethod def load(cls, path: PathLike): + """ + Takes a file generated by 'dump' and creates a new ingress handler with those records + """ return cls.loads(Path(path).read_text()) @classmethod def loads(cls, s: str): + """ + Takes the string output by 'dumps' and creates a new ingress handler with those records + """ self = cls.__new__(cls) records = [] for record in json.loads(s):