From a2ae970b650600f4dc3db4fa26c0a8cafe62136e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 21 Oct 2019 13:42:14 +0200 Subject: [PATCH] added docstrings --- pype/avalon_apps/rest_api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pype/avalon_apps/rest_api.py b/pype/avalon_apps/rest_api.py index d58d080339..ae027383a1 100644 --- a/pype/avalon_apps/rest_api.py +++ b/pype/avalon_apps/rest_api.py @@ -52,6 +52,7 @@ class AvalonRestApi(RestApi): output = self.result_to_json(assets) return CallbackResult(data=output) + # identificator can be specified with url query (default is `name`) identificator = request.query.get("identificator", "name") asset = self.dbcon[_project_name].find_one({ @@ -68,6 +69,12 @@ class AvalonRestApi(RestApi): )) def result_to_json(self, result): + """ Converts result of MongoDB query to dict without $oid (ObjectId) + keys with help of regex matching. + + ..note: + This will convert object type entries similar to ObjectId. + """ bson_json = bson.json_util.dumps(result) # Replace "{$oid: "{entity id}"}" with "{entity id}" regex1 = '(?P{\"\$oid\": \"[^\"]+\"})'