ssorj commented on a change in pull request #192: Changed Python API to better handle strings where symbo… URL: https://github.com/apache/qpid-proton/pull/192#discussion_r333151329
########## File path: python/proton/_message.py ########## @@ -430,6 +430,31 @@ def _set_reply_to_group_id(self, value): :raise: :exc:`MessageException` if there is any Proton error when using the setter. """) + def _get_instructions(self): + return self.instruction_dict + def _set_instructions(self, instructions): + if isinstance(instructions, dict): + self.instruction_dict = AnnotationDict(instructions, throw=False) + else: + self.instruction_dict = instructions + instructions = property(_get_instructions, _set_instructions, doc=""" + Delivery annotations as a dictionary of key/values. The AMQP 1.0 + specification restricts this dictionary to have keys that are either + :class:`symbol` or :class:`ulong` types. It is possible to use + the special ``dict`` subclass :class:`AnnotationDict` as it + will by default enforce these restrictions on construction. In addition, + if a string type is used, it will be silently converted into the + required symbol. + + >>> from proton import symbol, ulong, Message, AnnotationDict + >>> msg = Message() + >>> msg.instructions = AnnotationDict({'one':1, symbol('two'):2, ulong(3):'three'}) + >>> msg.instructions + AnnotationDict({symbol('one'): 1, symbol('two'): 2, ulong(3): 'three'}) + + :type: :class:`AnnotationDict`. Any ``dict`` with :class:`ulong` or :class:`symbol` keys. + """) + Review comment: The absence of an empty line after the function def or property declaration (as the other functions in this file have) makes it a lot harder to read. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org