# Path: pympler/asizeof.py
# def asizeof(self, *objs, **opts):
#     '''Return the combined size of the given objects
#        (with modified options, see method **set**).
#     '''
#     if opts:
#         self.set(**opts)
#     self.exclude_refs(*objs)  # skip refs to objs
#     return sum(self._sizer(o, 0, 0, None) for o in objs)
# 
# Path: pympler/garbagegraph.py
# class GarbageGraph(ReferenceGraph):
#     """
#     The ``GarbageGraph`` is a ``ReferenceGraph`` that illustrates the objects
#     building reference cycles. The garbage collector is switched to debug mode
#     (all identified garbage is stored in `gc.garbage`) and the garbage
#     collector is invoked. The collected objects are then illustrated in a
#     directed graph.
# 
#     Large graphs can be reduced to the actual cycles by passing ``reduce=True``
#     to the constructor.
# 
#     It is recommended to disable the garbage collector when using the
#     ``GarbageGraph``.
# 
#     >>> from pympler.garbagegraph import GarbageGraph, start_debug_garbage
#     >>> start_debug_garbage()
#     >>> l = []
#     >>> l.append(l)
#     >>> del l
#     >>> gb = GarbageGraph()
#     >>> gb.render('garbage.eps')
#     True
#     """
#     def __init__(self, reduce=False, collectable=True):
#         """
#         Initialize the GarbageGraph with the objects identified by the garbage
#         collector. If `collectable` is true, every reference cycle is recorded.
#         Otherwise only uncollectable objects are reported.
#         """
#         if collectable:
#             gc.set_debug(gc.DEBUG_SAVEALL)
#         else:
#             gc.set_debug(0)
#         gc.collect()
# 
#         ReferenceGraph.__init__(self, gc.garbage, reduce)
# 
#     def print_stats(self, stream=None):
#         """
#         Log annotated garbage objects to console or file.
# 
#         :param stream: open file, uses sys.stdout if not given
#         """
#         if not stream:  # pragma: no cover
#             stream = sys.stdout
#         self.metadata.sort(key=lambda x: -x.size)
#         stream.write('%-10s %8s %-12s %-46s\n' % ('id', 'size', 'type',
#                                                   'representation'))
#         for g in self.metadata:
#             stream.write('0x%08x %8d %-12s %-46s\n' % (g.id, g.size,
#                                                        trunc(g.type, 12),
#                                                        trunc(g.str, 46)))
#         stream.write('Garbage: %8d collected objects (%s in cycles): %12s\n' %
#                      (self.count, self.num_in_cycles, pp(self.total_size)))
# 
# Path: pympler/process.py
# class _ProcessMemoryInfo(object):
# class _ProcessMemoryInfoPS(_ProcessMemoryInfo):
# class _ProcessMemoryInfoProc(_ProcessMemoryInfo):
#     class _ProcessMemoryInfoResource(_ProcessMemoryInfo):
#         class _ProcessMemoryInfoWin32(_ProcessMemoryInfo):
# class ThreadInfo(object):
#     def __init__(self) -> None:
#     def __repr__(self) -> str:
#     def update(self) -> bool:
#     def __sub__(self, other: '_ProcessMemoryInfo') -> Iterable[Tuple[str, int]]:
# def is_available() -> bool:
#     def update(self) -> bool:
#     def update(self) -> bool:
#                 def size_in_bytes(x: str) -> int:
#         def update(self) -> bool:
#             def update(self) -> bool:
#     def __init__(self, thread: threading.Thread):
# def get_current_threads() -> Iterable[ThreadInfo]:
# def get_current_thread_id() -> int:
# 
# Path: pympler/util/stringutils.py
# def safe_repr(obj: Any, clip: Optional[int] = None) -> str:
#     """
#     Convert object to string representation, yielding the same result a `repr`
#     but catches all exceptions and returns 'N/A' instead of raising the
#     exception. Strings may be truncated by providing `clip`.
# 
#     >>> safe_repr(42)
#     '42'
#     >>> safe_repr('Clipped text', clip=8)
#     'Clip..xt'
#     >>> safe_repr([1,2,3,4], clip=8)
#     '[1,2..4]'
#     """
#     try:
#         s = repr(obj)
#         if not clip or len(s) <= clip:
#             return s
#         else:
#             return s[:clip - 4] + '..' + s[-2:]
#     except:
#         return 'N/A'


import sys
import os
import threading
    import bottle
from inspect import getouterframes
from json import dumps
from shutil import rmtree
from tempfile import mkdtemp
from threading import Thread
from weakref import WeakValueDictionary
from wsgiref.simple_server import make_server
from pympler import asizeof
from pympler.garbagegraph import GarbageGraph
from pympler.process import get_current_threads, ProcessMemoryInfo
from pympler.util.stringutils import safe_repr
    from pympler.util import bottle
        server.id2ref[oid] = obj
    except TypeError:
        server.id2obj[oid] = obj
    return str(oid)


def get_obj(ref):
    """Get object from string reference."""
    oid = int(ref)
    return server.id2ref.get(oid) or server.id2obj[oid]


pympler_path = os.path.dirname(os.path.abspath(__file__))
static_files = os.path.join(pympler_path, 'templates')

bottle.TEMPLATE_PATH.append(static_files)


@bottle.route('/')
@bottle.view('index')
def root():
    """Get overview."""
    pmi = ProcessMemoryInfo()
    return dict(processinfo=pmi)


@bottle.route('/process')
@bottle.view('process')
def process():
    """Get process overview."""

# Path: pympler/asizeof.py
# def asizeof(self, *objs, **opts):
#     '''Return the combined size of the given objects
#        (with modified options, see method **set**).
#     '''
#     if opts:
#         self.set(**opts)
#     self.exclude_refs(*objs)  # skip refs to objs
#     return sum(self._sizer(o, 0, 0, None) for o in objs)
# 
# Path: pympler/garbagegraph.py
# class GarbageGraph(ReferenceGraph):
#     """
#     The ``GarbageGraph`` is a ``ReferenceGraph`` that illustrates the objects
#     building reference cycles. The garbage collector is switched to debug mode
#     (all identified garbage is stored in `gc.garbage`) and the garbage
#     collector is invoked. The collected objects are then illustrated in a
#     directed graph.
# 
#     Large graphs can be reduced to the actual cycles by passing ``reduce=True``
#     to the constructor.
# 
#     It is recommended to disable the garbage collector when using the
#     ``GarbageGraph``.
# 
#     >>> from pympler.garbagegraph import GarbageGraph, start_debug_garbage
#     >>> start_debug_garbage()
#     >>> l = []
#     >>> l.append(l)
#     >>> del l
#     >>> gb = GarbageGraph()
#     >>> gb.render('garbage.eps')
#     True
#     """
#     def __init__(self, reduce=False, collectable=True):
#         """
#         Initialize the GarbageGraph with the objects identified by the garbage
#         collector. If `collectable` is true, every reference cycle is recorded.
#         Otherwise only uncollectable objects are reported.
#         """
#         if collectable:
#             gc.set_debug(gc.DEBUG_SAVEALL)
#         else:
#             gc.set_debug(0)
#         gc.collect()
# 
#         ReferenceGraph.__init__(self, gc.garbage, reduce)
# 
#     def print_stats(self, stream=None):
#         """
#         Log annotated garbage objects to console or file.
# 
#         :param stream: open file, uses sys.stdout if not given
#         """
#         if not stream:  # pragma: no cover
#             stream = sys.stdout
#         self.metadata.sort(key=lambda x: -x.size)
#         stream.write('%-10s %8s %-12s %-46s\n' % ('id', 'size', 'type',
#                                                   'representation'))
#         for g in self.metadata:
#             stream.write('0x%08x %8d %-12s %-46s\n' % (g.id, g.size,
#                                                        trunc(g.type, 12),
#                                                        trunc(g.str, 46)))
#         stream.write('Garbage: %8d collected objects (%s in cycles): %12s\n' %
#                      (self.count, self.num_in_cycles, pp(self.total_size)))
# 
# Path: pympler/process.py
# class _ProcessMemoryInfo(object):
# class _ProcessMemoryInfoPS(_ProcessMemoryInfo):
# class _ProcessMemoryInfoProc(_ProcessMemoryInfo):
#     class _ProcessMemoryInfoResource(_ProcessMemoryInfo):
#         class _ProcessMemoryInfoWin32(_ProcessMemoryInfo):
# class ThreadInfo(object):
#     def __init__(self) -> None:
#     def __repr__(self) -> str:
#     def update(self) -> bool:
#     def __sub__(self, other: '_ProcessMemoryInfo') -> Iterable[Tuple[str, int]]:
# def is_available() -> bool:
#     def update(self) -> bool:
#     def update(self) -> bool:
#                 def size_in_bytes(x: str) -> int:
#         def update(self) -> bool:
#             def update(self) -> bool:
#     def __init__(self, thread: threading.Thread):
# def get_current_threads() -> Iterable[ThreadInfo]:
# def get_current_thread_id() -> int:
# 
# Path: pympler/util/stringutils.py
# def safe_repr(obj: Any, clip: Optional[int] = None) -> str:
#     """
#     Convert object to string representation, yielding the same result a `repr`
#     but catches all exceptions and returns 'N/A' instead of raising the
#     exception. Strings may be truncated by providing `clip`.
# 
#     >>> safe_repr(42)
#     '42'
#     >>> safe_repr('Clipped text', clip=8)
#     'Clip..xt'
#     >>> safe_repr([1,2,3,4], clip=8)
#     '[1,2..4]'
#     """
#     try:
#         s = repr(obj)
#         if not clip or len(s) <= clip:
#             return s
#         else:
#             return s[:clip - 4] + '..' + s[-2:]
#     except:
#         return 'N/A'


# Path: pympler/web.py
import sys
import os
import threading
    import bottle
from inspect import getouterframes
from json import dumps
from shutil import rmtree
from tempfile import mkdtemp
from threading import Thread
from weakref import WeakValueDictionary
from wsgiref.simple_server import make_server
from pympler import asizeof
from pympler.garbagegraph import GarbageGraph
from pympler.process import get_current_threads, ProcessMemoryInfo
from pympler.util.stringutils import safe_repr
    from pympler.util import bottle

        server.id2ref[oid] = obj
    except TypeError:
        server.id2obj[oid] = obj
    return str(oid)


def get_obj(ref):
    """Get object from string reference."""
    oid = int(ref)
    return server.id2ref.get(oid) or server.id2obj[oid]


pympler_path = os.path.dirname(os.path.abspath(__file__))
static_files = os.path.join(pympler_path, 'templates')

bottle.TEMPLATE_PATH.append(static_files)


@bottle.route('/')
@bottle.view('index')
def root():
    """Get overview."""
    pmi = ProcessMemoryInfo()
    return dict(processinfo=pmi)


@bottle.route('/process')
@bottle.view('process')
def process():
    """Get process overview."""

    pmi = ProcessMemoryInfo()