Determines whether a given command or subcommand is considered "keyless". A keyless command does not operate on specific keys, which is determined based on the first key position in the command or subcommand details. If the command or subcommand's first key position
(
self, command_name: str, subcommand_name: Optional[str] = None
)
| 508 | return keys |
| 509 | |
| 510 | async def _is_keyless_command( |
| 511 | self, command_name: str, subcommand_name: Optional[str] = None |
| 512 | ) -> bool: |
| 513 | """ |
| 514 | Determines whether a given command or subcommand is considered "keyless". |
| 515 | |
| 516 | A keyless command does not operate on specific keys, which is determined based |
| 517 | on the first key position in the command or subcommand details. If the command |
| 518 | or subcommand's first key position is zero or negative, it is treated as keyless. |
| 519 | |
| 520 | Parameters: |
| 521 | command_name: str |
| 522 | The name of the command to check. |
| 523 | subcommand_name: Optional[str], default=None |
| 524 | The name of the subcommand to check, if applicable. If not provided, |
| 525 | the check is performed only on the command. |
| 526 | |
| 527 | Returns: |
| 528 | bool |
| 529 | True if the specified command or subcommand is considered keyless, |
| 530 | False otherwise. |
| 531 | |
| 532 | Raises: |
| 533 | ValueError |
| 534 | If the specified subcommand is not found within the command or the |
| 535 | specified command does not exist in the available commands. |
| 536 | """ |
| 537 | if subcommand_name: |
| 538 | for subcommand in self.commands.get(command_name)["subcommands"]: |
| 539 | if str_if_bytes(subcommand[0]) == subcommand_name: |
| 540 | parsed_subcmd = self.parse_subcommand(subcommand) |
| 541 | return parsed_subcmd["first_key_pos"] <= 0 |
| 542 | raise ValueError( |
| 543 | f"Subcommand {subcommand_name} not found in command {command_name}" |
| 544 | ) |
| 545 | else: |
| 546 | command_details = self.commands.get(command_name, None) |
| 547 | if command_details is not None: |
| 548 | return command_details["first_key_pos"] <= 0 |
| 549 | |
| 550 | raise ValueError(f"Command {command_name} not found in commands") |
| 551 | |
| 552 | async def get_command_policies(self) -> Awaitable[PolicyRecords]: |
| 553 | """ |
no test coverage detected