mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added option for latin-1 encoding to splitSources.py
This commit is contained in:
parent
1c8745c54a
commit
581536178e
@ -59,25 +59,21 @@ if __name__ == '__main__':
|
|||||||
filePath = sys.argv[1]
|
filePath = sys.argv[1]
|
||||||
sys.excepthook = uncaught_exception_hook
|
sys.excepthook = uncaught_exception_hook
|
||||||
|
|
||||||
try:
|
|
||||||
# decide if file has multiple sources
|
# decide if file has multiple sources
|
||||||
|
try:
|
||||||
with open(filePath, mode='r', encoding='utf8', newline='') as f:
|
with open(filePath, mode='r', encoding='utf8', newline='') as f:
|
||||||
lines = f.read().splitlines()
|
lines = f.read().splitlines()
|
||||||
if len(lines) >= 1 and lines[0][:12] == "==== Source:":
|
except UnicodeDecodeError as error:
|
||||||
|
print(f'Found UnicodeDecodeError: {error.reason}. Will now attempt to read file using "latin-1" encoding.')
|
||||||
|
with open(filePath, mode='r', encoding='latin-1', newline='') as f:
|
||||||
|
lines = f.read().splitlines()
|
||||||
|
if len(lines) > 0 and lines[0][:12] == "==== Source:":
|
||||||
hasMultipleSources = True
|
hasMultipleSources = True
|
||||||
writeSourceToFile(lines)
|
writeSourceToFile(lines)
|
||||||
|
|
||||||
if hasMultipleSources:
|
if hasMultipleSources:
|
||||||
srcString = ""
|
srcString = ' '.join(createdSources)
|
||||||
for src in createdSources:
|
|
||||||
srcString += src + ' '
|
|
||||||
print(srcString)
|
print(srcString)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
except UnicodeDecodeError as ude:
|
|
||||||
print("UnicodeDecodeError in '" + filePath + "': " + str(ude))
|
|
||||||
print("This is expected for some tests containing invalid utf8 sequences. "
|
|
||||||
"Exception will be ignored.")
|
|
||||||
sys.exit(2)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user