Skip to content

Commit

Permalink
adding docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Moore committed Feb 12, 2022
1 parent 1f38bba commit 503eb1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/innoldb/qldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ def _init_fixtures(self):
log.error(e)

def _init_history(self):
"""Initializes the `innoldb.qldb.Document` revision history. After this method is invoked, the `self.strands` attribute will be populated with an array of `innoldb.qldb.Document` ordered over the revision history from earliest to latest.
"""
self.strands = []
history = Query(self.table).history(self.meta_id)
for doc in history:
self.strands.append(
Document(self.table, id=self.id, snapshot=doc.data))

def _load(self, snapshot=None, nest=None, nester=None):
"""Parse the `snapshot` into `innoldab.qldb.Document` attributes. If `nest` and `nester` are passed in, the function executes recursively, drilling down through the nodes in the `snapshot` and recursively generating the document structure.
"""Parse the `snapshot` into `innoldb.qldb.Document` attributes. If `nest` and `nester` are passed in, the function executes recursively, drilling down through the nodes in the `snapshot` and recursively generating the document structure.
:param snapshot: `dict` of attributes to append to self, defaults to `None`
:type snapshot: dict, optional
Expand All @@ -116,7 +118,7 @@ def _load(self, snapshot=None, nest=None, nester=None):
if snapshot is not None:
if isinstance(snapshot, Strut):
snapshot = vars(snapshot)

for key, value in snapshot.items():

if isinstance(value, dict):
Expand Down
5 changes: 5 additions & 0 deletions src/innoldb/static/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ def __init__(self, **kwargs):
self.__dict__.update(kwargs)

class StrutEncoder(json.JSONEncoder):
"""Encoder object to deserialize `innoldb.static.objects.Strut` into string.
"""
def default(self, obj):
"""Method to convert `innoldb.static.objects.Strut` into deserializable object. Overrides `json.default` and adds a check for `Strut` objects.
"""
if isinstance(obj, Strut):
return vars(obj)
return json.JSONEncoder.default(self, obj)

0 comments on commit 503eb1b

Please sign in to comment.