Return a debug representation of a dict or OrderedDict.
15855
def repr_dict(_dict, indent):
    """"""
    # pprint represents OrderedDict objects using the tuple init syntax,
    # which is not very readable. Therefore, dictionaries are iterated over.
    if _dict is None:
        return 'None'
    if not isinstance(_dict, Mapping):
        raise TypeError("Object must be a mapping, but is a %s" %
                        type(_dict))
    if isinstance(_dict, OrderedDict):
        kind = 'ordered'
        ret = '%s {\n' % kind  # non standard syntax for the kind indicator
        for key in six.iterkeys(_dict):
            value = _dict[key]
            ret += _indent('%r: %r,\n' % (key, value), 2)
    else:  # dict
        kind = 'sorted'
        ret = '%s {\n' % kind  # non standard syntax for the kind indicator
        for key in sorted(six.iterkeys(_dict)):
            value = _dict[key]
            ret += _indent('%r: %r,\n' % (key, value), 2)
    ret += '}'
    ret = repr_text(ret, indent=indent)
    return ret.lstrip(' ')
699704
def to_dict(self, minimal=False):

        """"""

        data = collections.OrderedDict()

        if minimal:

            # In the minimal representation we just output the value

            data['value'] = self._to_python_type(self.value)

        else:

            # In the complete representation we output everything is needed to re-build the object

            data['value'] = self._to_python_type(self.value)
            data['desc'] = str(self.description)
            data['min_value'] = self._to_python_type(self.min_value)
            data['max_value'] = self._to_python_type(self.max_value)
            # We use our own thread-safe format for the unit
            data['unit'] = self.unit.to_string(format='threadsafe')

        return data
1263639
def _ordereddict2dict(input_ordered_dict):
    '''
    
    '''
    return salt.utils.json.loads(salt.utils.json.dumps(input_ordered_dict))
959449
def dict(self):
        
        from collections import OrderedDict
        SKIP_KEYS = ()
        return OrderedDict(
            (p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in SKIP_KEYS)
429444
def debug(context):
    

    from pprint import pformat
    output = [pformat(val) for val in context]
    output.append('\n\n')
    output.append(pformat(sys.modules))
    return ''.join(output)
66569
def debugObject(object, cat, format, *args):
    
    doLog(DEBUG, object, cat, format, args)
42396
def diagnostics(self):
        
        diag_dict = {}
        for key in self._diag_vars:
            try:
                #diag_dict[key] = getattr(self,key)
                #  using self.__dict__ doesn't count diagnostics defined as properties
                diag_dict[key] = self.__dict__[key]
            except:
                pass
        return diag_dict
404536
def debug_info(self):
        """"""
        return [tuple(imap(int, x.split('='))) for x in
                self._debug_info.split('&')]
1126744
def as_dict(self, ordered=False):
        """"""
        items = zip(self.keys(), self.values())

        return OrderedDict(items) if ordered else dict(items)
604376
def parse_debug(self, inputstring):
        """"""
        return self.parse(inputstring, self.file_parser, {"strip": True}, {"header": "none", "initial": "none", "final_endline": False})
486101
def debug(trace=True, backtrace=1, other=None, output=sys.stderr):
    """"""
    from pprint import pprint
    import traceback
    def debugdeco(func):
        def tracer(frame, event, arg):
            print>>output, '--- Tracer: %s, %r' % (event, arg)
            traceback.print_stack(frame, 1, output)
            return tracer
        def wrapped(*a, **k):
            print>>output
            print>>output, '--- Calling %s.%s with:' % (
                getattr(func, '__module__', ''),
                func.__name__
            )
            for i in enumerate(a):
                print>>output, '    | %s: %s' % i
            print>>output, '    | ',
            pprint(k, output)
            print>>output, '    From:'
            for i in traceback.format_stack(sys._getframe(1), backtrace):
                print>>output, i,
            if other:
                print>>output, '---      [ %r ]' % (other(func,a,k))
            if trace: sys.settrace(tracer)
            ret = func(*a, **k)
            if trace: sys.settrace(None)
            #~ a = list(a)
            print>>output, '--- %s.%s returned: %r' % (
                getattr(func, '__module__', ''),
                func.__name__,
                #~ ret not in a and ret or "ARG%s"%a.index(ret)
                ret
            )
            return ret
        return wrapped
    return debugdeco
1298739
def debug(self, i: int=None) -> str:
        
        head = "[" + colors.yellow("debug") + "]"
        if i is not None:
            head = str(i) + " " + head
        return head
214287
def ufloatDict_stdev(self, ufloat_dict):
        ''
        return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.std_dev, ufloat_dict.values())))
1335947
def debug(func):
    """"""
    @wraps(func)
    def wrapper(*args, **kwargs):
        print("{} args: {} kwargs: {}".format(func.__name__, args, kwargs))
        return func(*args, **kwargs)

    return wrapper
954994
def _ordered(generator, *args, **kwargs):
    """"""
    unordered_dict = {k: v for k, v in generator(*args, **kwargs)}
    keys = sorted(list(dict(unordered_dict).keys()))
    result = OrderedDict()
    for key in keys:
        result[key] = unordered_dict[key]

    return result
554313
def debugArgsToDict(a):
    
    s = a.replace('+', ' ')
    s = s.replace('=', ':')
    s = re.sub(r'([A-Z][A-Z_]+)', r"'\1'", s)
    return ast.literal_eval('{ ' + s + ' }')
396423
def parse_dict(self, attrs):
        """"""
        attrs = attrs or {}
        ident = attrs.get("id", "")
        classes = attrs.get("classes", [])
        kvs = OrderedDict((k, v) for k, v in attrs.items()
                          if k not in ("classes", "id"))

        return ident, classes, kvs