Skip to content

Commit

Permalink
pyevmasm: blacken
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Jun 17, 2022
1 parent eacc993 commit db6a28b
Show file tree
Hide file tree
Showing 2 changed files with 305 additions and 159 deletions.
56 changes: 46 additions & 10 deletions pyevmasm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,49 @@


def main():
parser = argparse.ArgumentParser(description="pyevmasm the EVM assembler and disassembler")
parser = argparse.ArgumentParser(
description="pyevmasm the EVM assembler and disassembler"
)
group_action = parser.add_mutually_exclusive_group(required=True)
group_action.add_argument("-a", "--assemble", action="store_true", help="Assemble EVM instructions to opcodes")
group_action.add_argument("-d", "--disassemble", action="store_true", help="Disassemble EVM to opcodes")
group_action.add_argument("-t", "--print-opcode-table", action="store_true", help="List supported EVM opcodes")
parser.add_argument("-bi", "--binary-input", action="store_true", help="Binary input mode (-d only)")
parser.add_argument("-bo", "--binary-output", action="store_true", help="Binary output mode (-a only)")
group_action.add_argument(
"-a",
"--assemble",
action="store_true",
help="Assemble EVM instructions to opcodes",
)
group_action.add_argument(
"-d", "--disassemble", action="store_true", help="Disassemble EVM to opcodes"
)
group_action.add_argument(
"-t",
"--print-opcode-table",
action="store_true",
help="List supported EVM opcodes",
)
parser.add_argument(
"-i", "--input", nargs="?", default=sys.stdin, type=argparse.FileType("r"), help="Input file, default=stdin"
"-bi", "--binary-input", action="store_true", help="Binary input mode (-d only)"
)
parser.add_argument(
"-o", "--output", nargs="?", default=sys.stdout, type=argparse.FileType("w"), help="Output file, default=stdout"
"-bo",
"--binary-output",
action="store_true",
help="Binary output mode (-a only)",
)
parser.add_argument(
"-i",
"--input",
nargs="?",
default=sys.stdin,
type=argparse.FileType("r"),
help="Input file, default=stdin",
)
parser.add_argument(
"-o",
"--output",
nargs="?",
default=sys.stdout,
type=argparse.FileType("w"),
help="Output file, default=stdout",
)
parser.add_argument(
"-f",
Expand All @@ -46,7 +77,8 @@ def main():
fork = block_to_fork(block_number)
except ValueError:
sys.stderr.write(
"Wrong fork name or block number. " "Please provide an integer or one of %s.\n" % accepted_forks
"Wrong fork name or block number. "
"Please provide an integer or one of %s.\n" % accepted_forks
)
sys.exit(1)
else:
Expand All @@ -55,7 +87,11 @@ def main():
instruction_table = instruction_tables[fork]
if args.print_opcode_table:
for instr in instruction_table:
print("0x{:02x}: {:16s} {:s}".format(instr.opcode, instr.name, instr.description))
print(
"0x{:02x}: {:16s} {:s}".format(
instr.opcode, instr.name, instr.description
)
)
sys.exit(0)

if args.assemble:
Expand Down
Loading

0 comments on commit db6a28b

Please sign in to comment.