aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj38.park@gmail.com>2024-03-17 10:21:08 -0700
committerSeongJae Park <sj38.park@gmail.com>2024-03-17 10:21:08 -0700
commit807a63b49f5059b487ed1c3bac709c82b30eb9da (patch)
tree7041d2681590e668859831fd7c3121df6ed87a77
parent8ab24ee7cbec7f1c378af80d4f35571667a9aa68 (diff)
downloaddamo-807a63b49f5059b487ed1c3bac709c82b30eb9da.tar.gz
_damo_fs: Support debugging-purpose ops printing on its own
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r--_damo_fs.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/_damo_fs.py b/_damo_fs.py
index 87b9405a..47f055fb 100644
--- a/_damo_fs.py
+++ b/_damo_fs.py
@@ -4,6 +4,12 @@ import os
import _damon
+debug_do_print = False
+
+def debug_print_ops(do_print):
+ global debug_do_print
+ debug_do_print = do_print
+
'''Returns content and error'''
def read_file(filepath):
try:
@@ -11,7 +17,7 @@ def read_file(filepath):
content = f.read()
except Exception as e:
return None, 'reading %s failed (%s)' % (filepath, e)
- if _damon.pr_debug_log:
+ if _damon.pr_debug_log or debug_do_print:
print('read \'%s\': \'%s\'' % (filepath, content.strip()))
return content, None
@@ -31,7 +37,7 @@ def read_files(root):
Returns None if success error string otherwise
'''
def write_file(filepath, content):
- if _damon.pr_debug_log:
+ if _damon.pr_debug_log or debug_do_print:
print('write \'%s\' to \'%s\'' % (content.strip(), filepath))
try:
with open(filepath, 'w') as f: