projects
/
mdis.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c815dad
)
README: update naming conventions
author
Dmitry Selyutin
<ghostmansd@gmail.com>
Tue, 13 Jun 2023 22:40:21 +0000
(
01:40
+0300)
committer
Dmitry Selyutin
<ghostmansd@gmail.com>
Tue, 13 Jun 2023 22:40:21 +0000
(
01:40
+0300)
README.md
patch
|
blob
|
history
diff --git
a/README.md
b/README.md
index 9fd6422063b8767d12e9aabaaa97da2955bbbec1..7284b66815fb7185cfad01197cd00f9fa2dec5fb 100644
(file)
--- a/
README.md
+++ b/
README.md
@@
-26,7
+26,7
@@
The example below shows how to override the way the dicts are traversed so that
class CustomWalker(mdis.walker.Walker):
@mdis.core.hook(dict)
class CustomWalker(mdis.walker.Walker):
@mdis.core.hook(dict)
- def
walk
_dict(self, instance):
+ def
dispatch
_dict(self, instance):
for (key, value) in instance.items():
yield (value, key)
yield from self((value, key))
for (key, value) in instance.items():
yield (value, key)
yield from self((value, key))
@@
-60,21
+60,21
@@
The example below shows how to execute some arbitrary code upon visiting an obje
class CustomVisitor(mdis.visitor.Visitor):
@mdis.core.hook(int)
@contextlib.contextmanager
class CustomVisitor(mdis.visitor.Visitor):
@mdis.core.hook(int)
@contextlib.contextmanager
- def
visit
_int(self, instance):
+ def
dispatch
_int(self, instance):
print("entering int")
yield (instance + 42)
print("leaving int")
@mdis.core.hook(str)
@contextlib.contextmanager
print("entering int")
yield (instance + 42)
print("leaving int")
@mdis.core.hook(str)
@contextlib.contextmanager
- def
visit
_str(self, instance):
+ def
dispatch
_str(self, instance):
print("entering str")
yield f"!!!{instance}!!!"
print("leaving str")
@mdis.core.hook(object)
@contextlib.contextmanager
print("entering str")
yield f"!!!{instance}!!!"
print("leaving str")
@mdis.core.hook(object)
@contextlib.contextmanager
- def
visit
_object(self, instance):
+ def
dispatch
_object(self, instance):
print("entering object")
yield instance
print("leaving object")
print("entering object")
yield instance
print("leaving object")