def _validate_index_level(self, level):
if isinstance(level, int):<EOL><INDENT>if level < <NUM_LIT:0> and level != -<NUM_LIT:1>:<EOL><INDENT>raise IndexError("<STR_LIT>"<EOL>"<STR_LIT>" % (level, ))<EOL><DEDENT>elif level > <NUM_LIT:0>:<EOL><INDENT>raise IndexError("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(level + <NUM_LIT:1>))<EOL><DEDENT><DEDENT>elif level != self.name:<EOL><INDENT>raise KeyError('<STR_LIT>' %<EOL>(level, self.name))<EOL><DEDENT>
Validate index level.

For single-level Index getting level number is a no-op, but some
verification must be done like in MultiIndex.