def ensure_hexadecimal_string(self, value, command=None):
if not HEX_PATTERN.match(value):<EOL><INDENT>msg = "<STR_LIT>"<EOL>if command:<EOL><INDENT>msg += "<STR_LIT>"<EOL>msg %= (value, command)<EOL><DEDENT>else:<EOL><INDENT>msg %= value<EOL><DEDENT>raise ValueError(msg)<EOL><DEDENT>return value<EOL>
Make sure the given value is a hexadecimal string.

:param value: The value to check (a string).
:param command: The command that produced the value (a string or :data:`None`).
:returns: The validated hexadecimal string.
:raises: :exc:`~exceptions.ValueError` when `value` is not a hexadecimal string.