From f465d2d0252e466477e77a84565088dc42687199 Mon Sep 17 00:00:00 2001
From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com>
Date: Fri, 4 Dec 2020 23:27:42 +0900
Subject: [PATCH 1/5] updating
---
.idea/workspace.xml | 32 ++++++++++++++++++++++++++++++++
pysnooper/tracer.py | 32 +++++++++++++++++++++-----------
2 files changed, 53 insertions(+), 11 deletions(-)
create mode 100644 .idea/workspace.xml
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..e4ff5c9
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1607091614772
+
+
+ 1607091614772
+
+
+
+
\ No newline at end of file
diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py
index 773ed1f..9eb23b7 100644
--- a/pysnooper/tracer.py
+++ b/pysnooper/tracer.py
@@ -325,7 +325,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. ####################################
@@ -397,7 +397,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]
@@ -426,11 +426,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. ###########################
@@ -474,9 +479,14 @@ 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()))
- # If meets return, write Return value of return_value_repr.
+ 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)
self.start_times.pop(frame, None)
@@ -488,8 +498,8 @@ class Tracer:
self.max_variable_length,
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 1b21c47b90fad856dd4565ca7afc4a81357661ec Mon Sep 17 00:00:00 2001
From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com>
Date: Sat, 5 Dec 2020 01:03:14 +0900
Subject: [PATCH 2/5] dd
---
.idea/workspace.xml | 59 ++++++++++++++++++++++++++++++++++++++++++
pysnooper/tracer.py | 18 ++++++-------
pysnooper/variables.py | 3 ++-
3 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e4ff5c9..216f115 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,5 +1,8 @@
+
+
+
@@ -14,9 +17,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -29,4 +62,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py
index 9eb23b7..1fd6284 100644
--- a/pysnooper/tracer.py
+++ b/pysnooper/tracer.py
@@ -325,7 +325,7 @@ class Tracer:
elapsed_time_string = pycompat.timedelta_format(duration)
indent = ' ' * 4 * (thread_global.depth + 1)
self.write(
- '\033[33m'+'{indent}Elapsed time: {elapsed_time_string}'+'\033[0m'.format(**locals())
+ '\033[33m' + '{indent}Elapsed time: {elapsed_time_string}' + '\033[0m'.format(**locals())
)
# #
### Finished writing elapsed time. ####################################
@@ -426,16 +426,16 @@ class Tracer:
for name, value_repr in local_reprs.items():
if name not in old_local_reprs:
- str = '{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')
+ 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')
+ self.write('\033[33m' + str[0:idx + 8] + '\033[34m' + str[idx + 8:] + '\033[0m')
elif old_local_reprs[name] != value_repr:
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')
+ self.write('\033[33m' + str[0:idx + 2] + '\033[34m' + str[idx + 2:] + '\033[0m')
# #
### Finished newish and modified variables. ###########################
@@ -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
@@ -483,7 +483,7 @@ class Tracer:
idx = str.find(" ")
for s in str.split():
- if(s.isdigit()): num = s
+ 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')
@@ -498,7 +498,7 @@ class Tracer:
self.max_variable_length,
self.normalize,
)
- self.write('\033[95m' + '{indent}Return value:.. {return_value_repr}'.
+ self.write('\033[95m' + '{indent}Return value:.. {name} = {return_value_repr}'.
format(**locals()) + '\033[0m')
if event == 'exception':
diff --git a/pysnooper/variables.py b/pysnooper/variables.py
index 2229c38..d286333 100644
--- a/pysnooper/variables.py
+++ b/pysnooper/variables.py
@@ -1,5 +1,6 @@
import itertools
import abc
+
try:
from collections.abc import Mapping, Sequence
except ImportError:
@@ -47,7 +48,7 @@ class BaseVariable(pycompat.ABC):
def __eq__(self, other):
return (isinstance(other, BaseVariable) and
- self._fingerprint == other._fingerprint)
+ self._fingerprint == other._fingerprint)
class CommonVariable(BaseVariable):
From 7f9337a412552282d37b73acbe5112b97720bc8a Mon Sep 17 00:00:00 2001
From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com>
Date: Sat, 5 Dec 2020 01:46:24 +0900
Subject: [PATCH 3/5] adding test case, error color handling
---
.idea/inspectionProfiles/Project_Default.xml | 14 ++
.idea/vcs.xml | 6 +
.idea/workspace.xml | 137 +++++++++++++++++--
pysnooper/tracer.py | 6 +-
test1.py | 18 +++
5 files changed, 166 insertions(+), 15 deletions(-)
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 .idea/vcs.xml
create mode 100644 test1.py
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..dce2ee5
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ 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/.idea/workspace.xml b/.idea/workspace.xml
index 216f115..ef82715 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,13 +3,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -20,10 +94,33 @@
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -47,6 +144,7 @@
+
@@ -62,30 +160,45 @@
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
\ No newline at end of file
diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py
index 1fd6284..13582b6 100644
--- a/pysnooper/tracer.py
+++ b/pysnooper/tracer.py
@@ -429,7 +429,7 @@ class Tracer:
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')
+ self.write('\033[95m' + 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:
@@ -498,14 +498,14 @@ class Tracer:
self.max_variable_length,
self.normalize,
)
- self.write('\033[95m' + '{indent}Return value:.. {name} = {return_value_repr}'.
+ 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()
if self.max_variable_length:
exception = utils.truncate(exception, self.max_variable_length)
- self.write('{indent}Exception:..... {exception}'.
+ self.write('\033[31m' + '{indent}Exception:..... {exception}'.
format(**locals()))
return self.trace
diff --git a/test1.py b/test1.py
new file mode 100644
index 0000000..b6156c0
--- /dev/null
+++ b/test1.py
@@ -0,0 +1,18 @@
+import pysnooper
+
+@pysnooper.snoop()
+def bubble(number):
+ a = [5, 0, 2, 3, 6, 9, 1, 7, 4]
+ if number == 1:
+ for i in range(0,11):
+ for j in range(i, 9):
+ if(a[j] < a[i]):
+ temp = a[i]
+ a[i] = a[j]
+ a[j] = temp
+ return a
+
+ else:
+ return [0]
+
+print(bubble(0))
\ No newline at end of file
From 2bc42336086da61f55c77903b3a035ede7f9c8b9 Mon Sep 17 00:00:00 2001
From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com>
Date: Sat, 5 Dec 2020 01:49:39 +0900
Subject: [PATCH 4/5] deleting .idea
---
.idea/inspectionProfiles/Project_Default.xml | 14 --
.idea/vcs.xml | 6 -
.idea/workspace.xml | 204 -------------------
3 files changed, 224 deletions(-)
delete mode 100644 .idea/inspectionProfiles/Project_Default.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 .idea/workspace.xml
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index dce2ee5..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index ef82715..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1607091614772
-
-
- 1607091614772
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From 09eaf0941c4e674cc8a75e0180d35cfce07b4c01 Mon Sep 17 00:00:00 2001
From: yunminjin2 <56184924+yunminjin2@users.noreply.github.com>
Date: Sat, 5 Dec 2020 01:50:04 +0900
Subject: [PATCH 5/5] Update .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index f855e00..c646f69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ build/
.coverage
htmlcov
+*.xml