[X2Go-Commits] [x2gobroker] 01/01: x2gobroker/uccsjson.py: Hide private Python class properties from JSON dict (like <obj>._api_version).
git-admin at x2go.org
git-admin at x2go.org
Fri May 4 11:26:08 CEST 2018
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2gobroker.
commit e1368e579119824a9239ef7d4d00208cc1c2bcc6
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Fri May 4 11:25:50 2018 +0200
x2gobroker/uccsjson.py: Hide private Python class properties from JSON dict (like <obj>._api_version).
---
x2gobroker/uccsjson.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/x2gobroker/uccsjson.py b/x2gobroker/uccsjson.py
index e582e29..102cebd 100644
--- a/x2gobroker/uccsjson.py
+++ b/x2gobroker/uccsjson.py
@@ -19,6 +19,8 @@
try: import simplejson as json
except ImportError: import json
+import re
+import copy
from x2gobroker.defaults import X2GOBROKER_LATEST_UCCS_API_VERSION as latest_api_version
@@ -28,9 +30,16 @@ def convert_to_builtin_type(obj):
Used for doing JSON dumps.
"""
- d = { }
- d.update(obj.__dict__)
- return d
+ d_obj = { }
+ d_obj.update(obj.__dict__)
+
+ d_obj_res = copy.deepcopy(d_obj)
+ # hide private object items (starting with "_") from the resulting dict
+ for key, val in d_obj.items():
+ if re.match("^_[a-zA-Z]{1}.*", key):
+ del d_obj_res[key]
+
+ return d_obj_res
class ManagementServer():
"""\
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
More information about the x2go-commits
mailing list