""" Encoding and decoding for dirac, Ids: i -> int I -> long f -> float b -> bool s -> string z -> datetime n -> none l -> list t -> tuple d -> dictionary """ from __future__ import print_function from __future__ import absolute_import from __future__ import division __RCSID__ = "b1199b790 (2021-12-09 16:16:00 +0100) Chris Burr " from past.builtins import long import six import datetime import os import functools import inspect import traceback from collections import defaultdict from pprint import pprint def _ord(char): """Convert a single character string to it's byte value In Python 2 a single byte is represented as a string whereas in Python 3 it is an integer. This function converts it as appropriate. """ if six.PY2: return char else: return ord(char) # This is a hack for Python 3 to make it possible to import DEncode # There is not point in porting DEncode to Python 3 as it will be removed as # part of the HTTPS transition. class types(object): IntType = int LongType = long if six.PY2 else int FloatType = float BooleanType = bool StringType = str UnicodeType = type(u"") NoneType = type(None) ListType = list TupleType = tuple DictType = dict # Setting this environment variable to any value will enable the dump of the debugging # call stack DIRAC_DEBUG_DENCODE_CALLSTACK = bool(os.environ.get("DIRAC_DEBUG_DENCODE_CALLSTACK", False)) # This global dictionary contains # { : set (