python scripts: Some pylint tweaks.

This commit is contained in:
Christian Parpart 2020-01-15 14:21:33 +01:00
parent 44e892634b
commit 54b81b0fda
2 changed files with 30 additions and 36 deletions

View File

@ -5,14 +5,14 @@ import glob
import subprocess
import json
solc = sys.argv[1]
report = open("report.txt", "wb")
SOLC_BIN = sys.argv[1]
REPORT_FILE = open("report.txt", "wb")
for optimize in [False, True]:
for f in sorted(glob.glob("*.sol")):
sources = {}
sources[f] = {'content': open(f, 'r').read()}
input = {
input_json = {
'language': 'Solidity',
'sources': sources,
'settings': {
@ -22,20 +22,20 @@ for optimize in [False, True]:
'outputSelection': {'*': {'*': ['evm.bytecode.object', 'metadata']}}
}
}
args = [solc, '--standard-json']
args = [SOLC_BIN, '--standard-json']
if optimize:
args += ['--optimize']
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:
result = json.loads(out.strip())
for filename in sorted(result['contracts'].keys()):
for contractName in sorted(result['contracts'][filename].keys()):
contractData = result['contracts'][filename][contractName]
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:
report.write(filename + ':' + contractName + ' NO BYTECODE\n')
report.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n')
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
except KeyError:
report.write(f + ": ERROR\n")
REPORT_FILE.write(f + ": ERROR\n")

View File

@ -8,12 +8,9 @@
import sys
import re
import os
import hashlib
from os.path import join
def extract_test_cases(path):
lines = open(path, 'rb').read().splitlines()
def extract_test_cases(_path):
lines = open(_path, 'rb').read().splitlines()
inside = False
delimiter = ''
@ -42,8 +39,5 @@ def extract_test_cases(path):
inside = True
delimiter = m.group(1)
if __name__ == '__main__':
path = sys.argv[1]
extract_test_cases(path)
extract_test_cases(sys.argv[1])