(lines)
| 34 | # expects the first line of lines to be "==== Source: sourceName ====" |
| 35 | # writes the following source into a file named sourceName |
| 36 | def 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 | |
| 54 | def split_sources(filePath, suppress_output = False): |
| 55 | sys.excepthook = uncaught_exception_hook |
no test coverage detected