MCPcopy Create free account
hub / github.com/ActiveState/code / grep2

Method grep2

recipes/Python/502268_Win_Registry_module/recipe-502268.py:91–110  ·  view source on GitHub ↗
(self, text, kv='both', typ=(rTyp['STR'],))

Source from the content-addressed store, hash-verified

89 if (v.typ in typ) and (text in v.val):
90 yield k, v
91 def grep2(self, text, kv='both', typ=(rTyp['STR'],)):
92 # a grep variant, might be more convinient in some cases
93 kb=None
94 for k in self.walk():
95 if kv in ('keys', 'both') and text in k.name:
96 if kv=='both':
97 yield k, False
98 kb=k
99 else:
100 yield k
101 if kv in ('vals', 'both'):
102 for v in k.vals:
103 if (v.typ in typ) and (text in v.val):
104 if kv=='both':
105 if k!=kb:
106 yield k, False
107 kb=k
108 yield v, True
109 else:
110 yield v
111 def create(self, path):
112 # create a subkey, and the path to it if necessary
113 k=self

Callers 1

recipe-502268.pyFile · 0.80

Calls 1

walkMethod · 0.95

Tested by

no test coverage detected