MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / crawl

Function crawl

applyheader.py:28–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28def crawl():
29 # folders = ["./dscribe/utils"]
30 # folders = ["./dscribe/kernels"]
31 # folders = ["./dscribe/core"]
32 folders = ["./dscribe/descriptors"]
33 for folder in folders:
34 for path, dirs, files in os.walk(folder):
35 for f in files:
36 filename = os.path.join(path, f)
37 if match_func(f):
38
39 with open(filename, "r+") as fh:
40 text = fh.read()
41
42 pos = 0
43
44 # Try to find coding.
45 match = re.search(coding_re, text)
46 if match is None:
47 text = coding_text + text
48 else:
49 pos = match.end()
50
51 # Try to find copyright. If not present add after coding
52 match = re.search(copyright_re, text)
53 if match is None:
54 text = text[0:pos] + copyright_text + text[pos:]
55
56 # Write new contents
57 fh.seek(0)
58 fh.write(text)
59 fh.truncate()
60
61crawl()

Callers 1

applyheader.pyFile · 0.85

Calls 1

match_funcFunction · 0.85

Tested by

no test coverage detected