|
[yoda-svn] yoda: 2 new changesetsYODA Mercurial yoda at projects.hepforge.orgFri Aug 25 20:30:02 BST 2017
details: https://yoda.hepforge.org/hg/yoda/rev/f10bbd8e01fe branches: changeset: 1380:f10bbd8e01fe user: Andy Buckley <andy at insectnation.org> date: Fri Aug 25 17:47:42 2017 +0100 description: Return annotations as Python native types via the yaml module if possible details: https://yoda.hepforge.org/hg/yoda/rev/3a1c29fcdca6 branches: changeset: 1381:3a1c29fcdca6 user: Andy Buckley <andy at insectnation.org> date: Fri Aug 25 20:19:30 2017 +0100 description: Add moar docs diffs (23 lines): --- a/pyext/yoda/include/AnalysisObject.pyx Fri Aug 25 14:31:25 2017 +0100 +++ b/pyext/yoda/include/AnalysisObject.pyx Fri Aug 25 20:19:30 2017 +0100 @@ -45,9 +45,18 @@ return dict((k.lower(), self.annotation(k)) for k in self.annotations) def annotation(self, string k, default=None): - """Get annotation k from this object (falling back to default if not set).""" + """Get annotation k from this object (falling back to default if not set). + + The annotation string will be automatically converted to Python + native types as far as possible -- more complex types are possible + if the yaml module is installed.""" try: - return util._autotype(self.aoptr().annotation(string(k))) + astr = self.aoptr().annotation(string(k)) + try: + import yaml + return yaml.load(astr) + except ImportError: + return util._autotype(astr) except: return default
More information about the yoda-svn mailing list |