X-Git-Url: https://code.kerkeslager.com/?p=ton;a=blobdiff_plain;f=don%2F_shared.py;fp=don%2F_shared.py;h=9ce9ca4556856570d262e09096db2f9688513eac;hp=ca4c839026e493d6a66edd7ef2b9da3091f8cdee;hb=ce06e94ee5d876d364bad2e9cb19ccb5d9da8314;hpb=d19bdaf03aeb26d4812600347273a27d2c9b9caa diff --git a/don/_shared.py b/don/_shared.py index ca4c839..9ce9ca4 100644 --- a/don/_shared.py +++ b/don/_shared.py @@ -1,33 +1,6 @@ import collections -from don import constants - -_TYPES_TO_TAGS = { - int: constants.DEFAULT_INTEGER_ENCODING, - float: constants.DEFAULT_DECIMAL_ENCODING, - bytes: constants.BINARY, - str: constants.DEFAULT_STRING_ENCODING, - list: constants.LIST, - dict: constants.DICTIONARY, - collections.OrderedDict: constants.DICTIONARY, -} - -TaggedObject = collections.namedtuple('TaggedObject', ['tag', 'value']) - -def _tag(o): - if isinstance(o, TaggedObject): - return o - - if o is None: - return TaggedObject(tag = constants.VOID, value = o) - - if o is True: - return TaggedObject(tag = constants.TRUE, value = o) - - if o is False: - return TaggedObject(tag = constants.FALSE, value = o) - - return TaggedObject(tag = _TYPES_TO_TAGS[type(o)], value = o) +from don import tags ParseResult = collections.namedtuple( 'ParseResult',