def test_is_command_keyword(self): self.assertTrue(KeywordVerifier.is_command_keyword('COMMAND')) self.assertTrue( KeywordVerifier.is_command_keyword(Tokens.reindent(1) + 'COMMAND')) self.assertTrue( KeywordVerifier.is_command_keyword(Tokens.reindent(1) + 'ARGS')) self.assertFalse(KeywordVerifier.is_command_keyword('CMD')) self.assertFalse( KeywordVerifier.is_command_keyword(Tokens.reindent(2) + 'COMMAND'))
def __realign_commands(self, args: List[str]) -> list: diff = 0 if self.__settings.get('keyword_and_single_value_in_one_line') else CommandRealignModifier.__DIFF_BETWEEN_KEYWORD_AND_VALUE for i in range(len(args)): if KeywordVerifier.is_command_keyword(args[i]): for j in range(i + diff, len(args) - 1): if self.__verifier.is_keyword(args[j + 1]): break if Tokens.is_spacing_token(args[j]): args[j] = ' ' return args