def print_help(self) -> None: help_command: Command = Finder.find_only( [command for command in self._commands if command.name == 'help']) arguments: Dict[str, str] = help_command.parse_arguments() if 'command' in arguments: command_name: str = arguments['command'] user_command: Command = Finder.find_only([ command for command in self._commands if command.name == command_name ]) user_command.print_help() else: self._print_group_help()
def find_file(self, name: str, ignored_directories: List[Regex] = None) -> File: return Finder.find_only([ file_ for file_ in self.find_files(ignored_directories) if file_.name == name ])
def _find_command(self, index: int) -> Command: command_names: List[str] = [command.name for command in self._commands] user_input: str = sys.argv[index] if user_input not in command_names: raise ValueError( 'Invalid command \'{0}\' given'.format(user_input)) return Finder.find_only([ command for command in self._commands if command.name == user_input ])
def find_directory(self, name: str, ignored_directories: List[Regex] = None, regex: Regex = None) -> 'Directory': return Finder.find_only([ directory for directory in self.find_directories(ignored_directories, regex) if directory.name == name ])
def find_one_by_text(self, text: str) -> 'HtmlTag': return Finder.find_only(self.find_all_by_text(text))
def find_one_by_name(self, name: str) -> 'HtmlTag': return Finder.find_only(self.find_all_by_name(name))
def find_by_id(self, id_name: str) -> 'HtmlTag': return Finder.find_only(self._find_all_by_id(id_name))
def get_one_by_class(self, class_name: str) -> 'HtmlTag': return Finder.find_only(self.get_all_by_class(class_name))
def get_by_id(self, id_name: str) -> 'HtmlTag': return Finder.find_only([ child for child in self._children if 'id' in child.attributes and child.attributes['id'] == id_name ])
def find_one_by_attribute(self, name: str, value: str = None) -> 'XmlElement': return Finder.find_only(self.find_all_by_attribute(name, value))
def find_one_by_text(self, text: str) -> 'XmlElement': return Finder.find_only(self.find_all_by_text(text))
def find_one_by_name(self, name: str) -> 'XmlElement': return Finder.find_only(self.find_all_by_name(name))
def _find_flag(self, user_input_flag) -> Flag: return Finder.find_only([ flag for flag in self._flags if user_input_flag == flag.names[0] or user_input_flag == flag.names[1] ])
def get_directory(self, name: str) -> 'Directory': return Finder.find_only([ directory for directory in self.get_directories() if directory.name == name ])
def get_file(self, name: str) -> File: return Finder.find_only( [file_ for file_ in self.get_files() if file_.name == name])