MCPcopy
hub / github.com/Gallopsled/pwntools / append_example

Function append_example

examples/gen-README.py:20–38  ·  view source on GitHub ↗
(_arg, top, names)

Source from the content-addressed store, hash-verified

18'''
19
20def append_example(_arg, top, names):
21 global out
22 for name in names:
23 if not (name.endswith('.py') and name != __file__):
24 continue
25 path = os.path.join(top, name)[2:] # strip './'
26 log.info('-> %s' % path)
27 data = read(path).strip().decode()
28 if data[0:3] not in ('"""', "'''"):
29 log.warning(' Has no docstring!')
30 continue
31 try:
32 i = data.index(data[0:3], 3)
33 except ValueError:
34 log.warning(' Docstring is weird')
35 continue
36 doc = util.safeeval.const(data[0:i + 3])
37 out += '* `%s`\n' % path
38 out += '```%s```\n' % doc
39
40for path, dirs, files in os.walk('.', onerror=None):
41 append_example(dirs, path, sorted(files))

Callers 1

gen-README.pyFile · 0.85

Calls 4

infoMethod · 0.80
warningMethod · 0.80
indexMethod · 0.80
readFunction · 0.50

Tested by

no test coverage detected