<s> import os <EOL> import sys <EOL> import string <EOL> from copy import copy <EOL> from wlauto . core . instrumentation import SIGNAL_MAP , PRIORITY_MAP <EOL> from wlauto . utils . doc import format_simple_table <EOL> CONVINIENCE_ALIASES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:start>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> OUTPUT_TEMPLATE_FILE = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT:source>' , '<STR_LIT>' ) <EOL> def escape_trailing_underscore ( value ) : <EOL> if value . endswith ( '<STR_LIT:_>' ) : <EOL> return value [ : - <NUM_LIT:1> ] + '<STR_LIT>' <EOL> def generate_instrumentation_method_map ( outfile ) : <EOL> signal_table = format_simple_table ( [ ( k , v ) for k , v in SIGNAL_MAP . iteritems ( ) ] , <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] , align = '<STR_LIT>' ) <EOL> priority_table = format_simple_table ( [ ( escape_trailing_underscore ( k ) , v ) for k , v in PRIORITY_MAP . iteritems ( ) ] , <EOL> headers = [ '<STR_LIT>' , '<STR_LIT>' ] , align = '<STR_LIT>' ) <EOL> with open ( OUTPUT_TEMPLATE_FILE ) as fh : <EOL> template = string . Template ( fh . read ( ) ) <EOL> with open ( outfile , '<STR_LIT:w>' ) as wfh : <EOL> wfh . write ( template . substitute ( signal_names = signal_table , priority_prefixes = priority_table ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> generate_instrumentation_method_map ( sys . argv [ <NUM_LIT:1> ] ) </s>
