How to use the pysnooper.tracer.get_local_reprs function in PySnooper

To help you get started, we’ve selected a few PySnooper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ydf0509 / distributed_framework / function_scheduling_distributed_framework / utils / custom_pysnooper.py View on Github external
for i in range(1, self.depth):
                    _frame_candidate = _frame_candidate.f_back
                    if _frame_candidate is None:
                        return self.trace
                    elif _frame_candidate.f_code is self.target_code_object:
                        indent = ' ' * 4 * i
                        break
                else:
                    return self.trace
        else:
            indent = ''

        self.frame_to_old_local_reprs[frame] = old_local_reprs = \
            self.frame_to_local_reprs[frame]
        self.frame_to_local_reprs[frame] = local_reprs = \
            get_local_reprs(frame, variables=self.variables)

        modified_local_reprs = {}
        newish_local_reprs = {}

        for key, value in local_reprs.items():
            if key not in old_local_reprs:
                newish_local_reprs[key] = value
            elif old_local_reprs[key] != value:
                modified_local_reprs[key] = value

        newish_string = ('Starting var:.. ' if event == 'call' else
                         'New var:....... ')
        for name, value_repr in newish_local_reprs.items():
            self.write('{indent}{newish_string}{name} = {value_repr}'.format(
                **locals()))
        for name, value_repr in modified_local_reprs.items():