From f6c3cbd5654cba66b8109c9d2cad73d3fa2cbb3e Mon Sep 17 00:00:00 2001 From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com> Date: Sun, 29 Nov 2020 17:09:24 +0900 Subject: [PATCH 1/5] Update exception.py --- tests/samples/exception.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/samples/exception.py b/tests/samples/exception.py index bf6196f..6ca15f1 100644 --- a/tests/samples/exception.py +++ b/tests/samples/exception.py @@ -4,7 +4,6 @@ import pysnooper def foo(): raise TypeError('bad') - def bar(): try: foo() @@ -12,7 +11,6 @@ def bar(): str(1) raise - @pysnooper.snoop(depth=3) def main(): try: From 0d2bcc3f43d490ae57a4bae8eaa0be950eeca492 Mon Sep 17 00:00:00 2001 From: JINSUBY Date: Sun, 29 Nov 2020 17:29:09 +0900 Subject: [PATCH 2/5] LEEJINSUB_to_do_list --- LEEJINSUB_to_do_list.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 LEEJINSUB_to_do_list.txt diff --git a/LEEJINSUB_to_do_list.txt b/LEEJINSUB_to_do_list.txt new file mode 100644 index 0000000..4235b57 --- /dev/null +++ b/LEEJINSUB_to_do_list.txt @@ -0,0 +1,2 @@ +LEEJINSUB will be rewrite this list. +- add the comments \ No newline at end of file From f89af6180b7adc7fbd226c0ddf394750477c7eba Mon Sep 17 00:00:00 2001 From: JINSUBY Date: Fri, 4 Dec 2020 14:49:20 +0900 Subject: [PATCH 3/5] Color Change Code --- .idea/.gitignore | 8 +++++ .idea/PySnooper-8.iml | 8 +++++ .idea/deployment.xml | 28 ++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 4 +++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ example.py | 14 ++++++++ pysnooper/tracer.py | 32 ++++++++++++------- 9 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/PySnooper-8.iml create mode 100644 .idea/deployment.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 example.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5933d59 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../:\Users\Jinsuby\Desktop\PySnooper-8\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/PySnooper-8.iml b/.idea/PySnooper-8.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/PySnooper-8.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..d1048be --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..84fe515 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bf6a407 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/example.py b/example.py new file mode 100644 index 0000000..9b64ee5 --- /dev/null +++ b/example.py @@ -0,0 +1,14 @@ +import pysnooper + +@pysnooper.snoop() +def number_to_bits(number): + if number: + bits = [] + while number: + number, remainder = divmod(number, 2) + bits.insert(0,remainder) + return bits + else: + return [0] + +number_to_bits(6) \ No newline at end of file diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 56165d3..f04a3ec 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -142,7 +142,7 @@ class FileWriter(object): with open(self.path, 'w' if self.overwrite else 'a', encoding='utf-8') as output_file: output_file.write(s) - self.overwrite = False + self.overwrite = False333 thread_global = threading.local() @@ -322,7 +322,7 @@ class Tracer: elapsed_time_string = pycompat.timedelta_format(duration) indent = ' ' * 4 * (thread_global.depth + 1) self.write( - '{indent}Elapsed time: {elapsed_time_string}'.format(**locals()) + '\033[33m'+'{indent}Elapsed time: {elapsed_time_string}'+'\033[0m'.format(**locals()) ) # # ### Finished writing elapsed time. #################################### @@ -394,7 +394,7 @@ class Tracer: source_path, source = get_path_and_source_from_frame(frame) source_path = source_path if not self.normalize else os.path.basename(source_path) if self.last_source_path != source_path: - self.write(u'{indent}Source path:... {source_path}'. + self.write('\033[33m' + u'{indent}Source path:... {source_path}' + '\033[0m'. format(**locals())) self.last_source_path = source_path source_line = source[line_no - 1] @@ -423,11 +423,16 @@ class Tracer: for name, value_repr in local_reprs.items(): if name not in old_local_reprs: - self.write('{indent}{newish_string}{name} = {value_repr}'.format( - **locals())) + str = '{indent}{newish_string}{name} = {value_repr}'.format( **locals()) + idx = str.find(":") + if("Start" in str): + self.write('\033[33m' + str[0:idx+3] + '\033[34m' + str[idx+3:] + '\033[0m') + else: + self.write('\033[33m' + str[0:idx+8] + '\033[34m' + str[idx+8:] + '\033[0m') elif old_local_reprs[name] != value_repr: - self.write('{indent}Modified var:.. {name} = {value_repr}'.format( - **locals())) + str = '{indent}Modified var:.. {name} = {value_repr}'.format(**locals()) + idx = str.find("..") + self.write('\033[33m' + str[0:idx+2] + '\033[34m' + str[idx+2:] + '\033[0m') # # ### Finished newish and modified variables. ########################### @@ -471,8 +476,13 @@ class Tracer: self.write('{indent}Call ended by exception'. format(**locals())) else: - self.write(u'{indent}{timestamp} {thread_info}{event:9} ' - u'{line_no:4} {source_line}'.format(**locals())) + str = u'{indent}{timestamp} {thread_info}{event:9} 'u'{line_no:4} {source_line}'.format(**locals()) + idx = str.find(" ") + + for s in str.split(): + if(s.isdigit()): num = s + numidx = str.find(" " + num + " ") + self.write('\033[30m' + str[:idx] + '\033[32m' + str[idx:numidx] + '\033[36m' + str[numidx:] + '\033[0m') if event == 'return': self.frame_to_local_reprs.pop(frame, None) @@ -485,8 +495,8 @@ class Tracer: max_length=self.max_variable_length, normalize=self.normalize, ) - self.write('{indent}Return value:.. {return_value_repr}'. - format(**locals())) + self.write('\033[95m' + '{indent}Return value:.. {return_value_repr}'. + format(**locals()) + '\033[0m') if event == 'exception': exception = '\n'.join(traceback.format_exception_only(*arg[:2])).strip() From 29134e5f3627157682a873630685c5b2307712d5 Mon Sep 17 00:00:00 2001 From: JINSUBY Date: Fri, 4 Dec 2020 14:53:28 +0900 Subject: [PATCH 4/5] Code Color Change2 --- pysnooper/tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index f04a3ec..c743298 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -142,7 +142,7 @@ class FileWriter(object): with open(self.path, 'w' if self.overwrite else 'a', encoding='utf-8') as output_file: output_file.write(s) - self.overwrite = False333 + self.overwrite = False thread_global = threading.local() From a811d79754ed61b7d17a06139b3c0a805cec7d67 Mon Sep 17 00:00:00 2001 From: hojin915 <73058856+hojin915@users.noreply.github.com> Date: Fri, 4 Dec 2020 15:32:41 +0900 Subject: [PATCH 5/5] Update tracer.py --- pysnooper/tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 9eb23b7..ba34c27 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -455,7 +455,7 @@ class Tracer: if candidate_source_line.lstrip().startswith('def'): # Found the def line! - # Save line_no and sorce line + # Save line_no and source line line_no = candidate_line_no source_line = candidate_source_line break