def resolve_modifier_to_ansi_code(modifiername, colormode):
if colormode == terminal.NO_COLORS:  <EOL><INDENT>return '<STR_LIT>', '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>start_code, end_code = ansi.MODIFIERS[modifiername]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ColorfulError('<STR_LIT>'.format(<EOL>modifiername, ansi.MODIFIERS.keys()))<EOL><DEDENT>else:<EOL><INDENT>return ansi.ANSI_ESCAPE_CODE.format(<EOL>code=start_code), ansi.ANSI_ESCAPE_CODE.format(<EOL>code=end_code)<EOL><DEDENT>
Resolve the given modifier name to a valid
ANSI escape code.

:param str modifiername: the name of the modifier to resolve
:param int colormode: the color mode to use. See ``translate_rgb_to_ansi_code``

:returns str: the ANSI escape code for the modifier

:raises ColorfulError: if the given modifier name is invalid