MCPcopy Create free account
hub / github.com/argotorg/solidity / writeSourceToFile

Function writeSourceToFile

scripts/splitSources.py:36–52  ·  view source on GitHub ↗
(lines)

Source from the content-addressed store, hash-verified

34# expects the first line of lines to be "==== Source: sourceName ===="
35# writes the following source into a file named sourceName
36def writeSourceToFile(lines):
37 filePath, srcName = extractSourceName(lines[0])
38 # print("sourceName is ", srcName)
39 # print("filePath is", filePath)
40 if filePath:
41 os.system("mkdir -p " + filePath)
42 with open(srcName, mode='a+', encoding='utf8', newline='') as f:
43 for idx, line in enumerate(lines[1:]):
44 # write to file
45 if not line.startswith("==== Source:"):
46 f.write(line + '\n')
47
48 # recursive call if there is another source
49 else:
50 return [srcName] + writeSourceToFile(lines[1+idx:])
51
52 return [srcName]
53
54def split_sources(filePath, suppress_output = False):
55 sys.excepthook = uncaught_exception_hook

Callers 1

split_sourcesFunction · 0.85

Calls 1

extractSourceNameFunction · 0.85

Tested by

no test coverage detected