Commit 54740503 authored by Jim Fulton's avatar Jim Fulton

Simplified TransactionMetaData and added a deprecation warning for _extension

parent 14613505
...@@ -1289,31 +1289,17 @@ size. ...@@ -1289,31 +1289,17 @@ size.
class TransactionMetaData(object): class TransactionMetaData(object):
def __init__(self, user=u'', description=u'', extension=b''): def __init__(self, user=u'', description=u'', extension=b''):
self.user = user
self.description = description
if not isinstance(extension, dict):
extension = _compat.loads(extension) if extension else {}
self.extension = extension
@property
def user(self):
return self.__user
@user.setter
def user(self, user):
if not isinstance(user, bytes): if not isinstance(user, bytes):
user = user.encode('utf-8') user = user.encode('utf-8')
self.__user = user self.user = user
@property
def description(self):
return self.__description
@description.setter
def description(self, description):
if not isinstance(description, bytes): if not isinstance(description, bytes):
description = description.encode('utf-8') description = description.encode('utf-8')
self.__description = description self.description = description
if not isinstance(extension, dict):
extension = _compat.loads(extension) if extension else {}
self.extension = extension
def note(self, text): # for tests def note(self, text): # for tests
text = text.strip() text = text.strip()
...@@ -1324,13 +1310,12 @@ class TransactionMetaData(object): ...@@ -1324,13 +1310,12 @@ class TransactionMetaData(object):
else: else:
self.description = text self.description = text
@property @property
def extension(self): def _extension(self):
return self.__extension warnings.warn("_extension is deprecated, use extension",
DeprecationWarning)
@extension.setter return self.extension
def extension(self, v):
self.__extension = v @_extension.setter
def _extension(self, v):
_extension = extension self.extension = v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment