mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
python scripts: Some pylint tweaks.
This commit is contained in:
parent
44e892634b
commit
54b81b0fda
@ -5,14 +5,14 @@ import glob
|
|||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
solc = sys.argv[1]
|
SOLC_BIN = sys.argv[1]
|
||||||
report = open("report.txt", "wb")
|
REPORT_FILE = open("report.txt", "wb")
|
||||||
|
|
||||||
for optimize in [False, True]:
|
for optimize in [False, True]:
|
||||||
for f in sorted(glob.glob("*.sol")):
|
for f in sorted(glob.glob("*.sol")):
|
||||||
sources = {}
|
sources = {}
|
||||||
sources[f] = {'content': open(f, 'r').read()}
|
sources[f] = {'content': open(f, 'r').read()}
|
||||||
input = {
|
input_json = {
|
||||||
'language': 'Solidity',
|
'language': 'Solidity',
|
||||||
'sources': sources,
|
'sources': sources,
|
||||||
'settings': {
|
'settings': {
|
||||||
@ -22,20 +22,20 @@ for optimize in [False, True]:
|
|||||||
'outputSelection': {'*': {'*': ['evm.bytecode.object', 'metadata']}}
|
'outputSelection': {'*': {'*': ['evm.bytecode.object', 'metadata']}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args = [solc, '--standard-json']
|
args = [SOLC_BIN, '--standard-json']
|
||||||
if optimize:
|
if optimize:
|
||||||
args += ['--optimize']
|
args += ['--optimize']
|
||||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
(out, err) = proc.communicate(json.dumps(input))
|
(out, err) = proc.communicate(json.dumps(input_json))
|
||||||
try:
|
try:
|
||||||
result = json.loads(out.strip())
|
result = json.loads(out.strip())
|
||||||
for filename in sorted(result['contracts'].keys()):
|
for filename in sorted(result['contracts'].keys()):
|
||||||
for contractName in sorted(result['contracts'][filename].keys()):
|
for contractName in sorted(result['contracts'][filename].keys()):
|
||||||
contractData = result['contracts'][filename][contractName]
|
contractData = result['contracts'][filename][contractName]
|
||||||
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
||||||
report.write(filename + ':' + contractName + ' ' + contractData['evm']['bytecode']['object'] + '\n')
|
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['evm']['bytecode']['object'] + '\n')
|
||||||
else:
|
else:
|
||||||
report.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
||||||
report.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
report.write(f + ": ERROR\n")
|
REPORT_FILE.write(f + ": ERROR\n")
|
||||||
|
@ -8,12 +8,9 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
import hashlib
|
|
||||||
from os.path import join
|
|
||||||
|
|
||||||
def extract_test_cases(path):
|
def extract_test_cases(_path):
|
||||||
lines = open(path, 'rb').read().splitlines()
|
lines = open(_path, 'rb').read().splitlines()
|
||||||
|
|
||||||
inside = False
|
inside = False
|
||||||
delimiter = ''
|
delimiter = ''
|
||||||
@ -42,8 +39,5 @@ def extract_test_cases(path):
|
|||||||
inside = True
|
inside = True
|
||||||
delimiter = m.group(1)
|
delimiter = m.group(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
path = sys.argv[1]
|
extract_test_cases(sys.argv[1])
|
||||||
extract_test_cases(path)
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user