| 52 | return [srcName] |
| 53 | |
| 54 | def split_sources(filePath, suppress_output = False): |
| 55 | sys.excepthook = uncaught_exception_hook |
| 56 | |
| 57 | try: |
| 58 | # decide if file has multiple sources |
| 59 | with open(filePath, mode='r', encoding='utf8', newline='') as f: |
| 60 | lines = f.read().splitlines() |
| 61 | if len(lines) >= 1 and lines[0][:12] == "==== Source:": |
| 62 | srcString = "" |
| 63 | for src in writeSourceToFile(lines): |
| 64 | srcString += src + ' ' |
| 65 | if not suppress_output: |
| 66 | print(srcString) |
| 67 | return 0 |
| 68 | return 1 |
| 69 | |
| 70 | except UnicodeDecodeError as ude: |
| 71 | print("UnicodeDecodeError in '" + filePath + "': " + str(ude)) |
| 72 | print("This is expected for some tests containing invalid utf8 sequences. " |
| 73 | "Exception will be ignored.") |
| 74 | return 2 |
| 75 | |
| 76 | |
| 77 | if __name__ == '__main__': |