Format: application/octet-stream
⬇ Download File (9.9 KB)
   1  import sys
   2  from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload
   3  
   4  # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g
   5  if sys.version_info >= (3,):
   6      _Text = str
   7  else:
   8      _Text = Union[str, unicode]
   9  
  10  NO_DEFAULT: Tuple[_Text, ...]
  11  SUPPRESS_HELP: _Text
  12  SUPPRESS_USAGE: _Text
  13  
  14  def check_builtin(option: Option, opt: Any, value: _Text) -> Any: ...
  15  def check_choice(option: Option, opt: Any, value: _Text) -> Any: ...
  16  
  17  if sys.version_info < (3,):
  18      def isbasestring(x: Any) -> bool: ...
  19  
  20  class OptParseError(Exception):
  21      msg: _Text
  22      def __init__(self, msg: _Text) -> None: ...
  23  
  24  class BadOptionError(OptParseError):
  25      opt_str: _Text
  26      def __init__(self, opt_str: _Text) -> None: ...
  27  
  28  class AmbiguousOptionError(BadOptionError):
  29      possibilities: Iterable[_Text]
  30      def __init__(self, opt_str: _Text, possibilities: Sequence[_Text]) -> None: ...
  31  
  32  class OptionError(OptParseError):
  33      msg: _Text
  34      option_id: _Text
  35      def __init__(self, msg: _Text, option: Option) -> None: ...
  36  
  37  class OptionConflictError(OptionError): ...
  38  class OptionValueError(OptParseError): ...
  39  
  40  class HelpFormatter:
  41      NO_DEFAULT_VALUE: _Text
  42      _long_opt_fmt: _Text
  43      _short_opt_fmt: _Text
  44      current_indent: int
  45      default_tag: _Text
  46      help_position: Any
  47      help_width: Any
  48      indent_increment: int
  49      level: int
  50      max_help_position: int
  51      option_strings: Dict[Option, _Text]
  52      parser: OptionParser
  53      short_first: Any
  54      width: int
  55      def __init__(self, indent_increment: int, max_help_position: int, width: Optional[int], short_first: int) -> None: ...
  56      def _format__Text(self, _Text: _Text) -> _Text: ...
  57      def dedent(self) -> None: ...
  58      def expand_default(self, option: Option) -> _Text: ...
  59      def format_description(self, description: _Text) -> _Text: ...
  60      def format_epilog(self, epilog: _Text) -> _Text: ...
  61      def format_heading(self, heading: Any) -> _Text: ...
  62      def format_option(self, option: OptionParser) -> _Text: ...
  63      def format_option_strings(self, option: OptionParser) -> Any: ...
  64      def format_usage(self, usage: Any) -> _Text: ...
  65      def indent(self) -> None: ...
  66      def set_long_opt_delimiter(self, delim: _Text) -> None: ...
  67      def set_parser(self, parser: OptionParser) -> None: ...
  68      def set_short_opt_delimiter(self, delim: _Text) -> None: ...
  69      def store_option_strings(self, parser: OptionParser) -> None: ...
  70  
  71  class IndentedHelpFormatter(HelpFormatter):
  72      def __init__(
  73          self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ...
  74      ) -> None: ...
  75      def format_heading(self, heading: _Text) -> _Text: ...
  76      def format_usage(self, usage: _Text) -> _Text: ...
  77  
  78  class TitledHelpFormatter(HelpFormatter):
  79      def __init__(
  80          self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ...
  81      ) -> None: ...
  82      def format_heading(self, heading: _Text) -> _Text: ...
  83      def format_usage(self, usage: _Text) -> _Text: ...
  84  
  85  class Option:
  86      ACTIONS: Tuple[_Text, ...]
  87      ALWAYS_TYPED_ACTIONS: Tuple[_Text, ...]
  88      ATTRS: List[_Text]
  89      CHECK_METHODS: Optional[List[Callable[..., Any]]]
  90      CONST_ACTIONS: Tuple[_Text, ...]
  91      STORE_ACTIONS: Tuple[_Text, ...]
  92      TYPED_ACTIONS: Tuple[_Text, ...]
  93      TYPES: Tuple[_Text, ...]
  94      TYPE_CHECKER: Dict[_Text, Callable[..., Any]]
  95      _long_opts: List[_Text]
  96      _short_opts: List[_Text]
  97      action: _Text
  98      dest: Optional[_Text]
  99      nargs: int
 100      type: Any
 101      def __init__(self, *opts: Optional[_Text], **attrs: Any) -> None: ...
 102      def _check_action(self) -> None: ...
 103      def _check_callback(self) -> None: ...
 104      def _check_choice(self) -> None: ...
 105      def _check_const(self) -> None: ...
 106      def _check_dest(self) -> None: ...
 107      def _check_nargs(self) -> None: ...
 108      def _check_opt_strings(self, opts: Iterable[Optional[_Text]]) -> List[_Text]: ...
 109      def _check_type(self) -> None: ...
 110      def _set_attrs(self, attrs: Dict[_Text, Any]) -> None: ...
 111      def _set_opt_strings(self, opts: Iterable[_Text]) -> None: ...
 112      def check_value(self, opt: Any, value: Any) -> Any: ...
 113      def convert_value(self, opt: Any, value: Any) -> Any: ...
 114      def get_opt_string(self) -> _Text: ...
 115      def process(self, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ...
 116      def take_action(self, action: _Text, dest: _Text, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ...
 117      def takes_value(self) -> bool: ...
 118  
 119  make_option = Option
 120  
 121  class OptionContainer:
 122      _long_opt: Dict[_Text, Option]
 123      _short_opt: Dict[_Text, Option]
 124      conflict_handler: _Text
 125      defaults: Dict[_Text, Any]
 126      description: Any
 127      option_class: Type[Option]
 128      def __init__(self, option_class: Type[Option], conflict_handler: Any, description: Any) -> None: ...
 129      def _check_conflict(self, option: Any) -> None: ...
 130      def _create_option_mappings(self) -> None: ...
 131      def _share_option_mappings(self, parser: OptionParser) -> None: ...
 132      @overload
 133      def add_option(self, opt: Option) -> Option: ...
 134      @overload
 135      def add_option(self, *args: Optional[_Text], **kwargs: Any) -> Any: ...
 136      def add_options(self, option_list: Iterable[Option]) -> None: ...
 137      def destroy(self) -> None: ...
 138      def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ...
 139      def format_help(self, formatter: Optional[HelpFormatter]) -> _Text: ...
 140      def format_option_help(self, formatter: Optional[HelpFormatter]) -> _Text: ...
 141      def get_description(self) -> Any: ...
 142      def get_option(self, opt_str: _Text) -> Optional[Option]: ...
 143      def has_option(self, opt_str: _Text) -> bool: ...
 144      def remove_option(self, opt_str: _Text) -> None: ...
 145      def set_conflict_handler(self, handler: Any) -> None: ...
 146      def set_description(self, description: Any) -> None: ...
 147  
 148  class OptionGroup(OptionContainer):
 149      option_list: List[Option]
 150      parser: OptionParser
 151      title: _Text
 152      def __init__(self, parser: OptionParser, title: _Text, description: Optional[_Text] = ...) -> None: ...
 153      def _create_option_list(self) -> None: ...
 154      def set_title(self, title: _Text) -> None: ...
 155  
 156  class Values:
 157      def __init__(self, defaults: Optional[Mapping[str, Any]] = ...) -> None: ...
 158      def _update(self, dict: Mapping[_Text, Any], mode: Any) -> None: ...
 159      def _update_careful(self, dict: Mapping[_Text, Any]) -> None: ...
 160      def _update_loose(self, dict: Mapping[_Text, Any]) -> None: ...
 161      def ensure_value(self, attr: _Text, value: Any) -> Any: ...
 162      def read_file(self, filename: _Text, mode: _Text) -> None: ...
 163      def read_module(self, modname: _Text, mode: _Text) -> None: ...
 164      def __getattr__(self, name: str) -> Any: ...
 165      def __setattr__(self, name: str, value: Any) -> None: ...
 166  
 167  class OptionParser(OptionContainer):
 168      allow_interspersed_args: bool
 169      epilog: Optional[_Text]
 170      formatter: HelpFormatter
 171      largs: Optional[List[_Text]]
 172      option_groups: List[OptionParser]
 173      option_list: List[Option]
 174      process_default_values: Any
 175      prog: Optional[_Text]
 176      rargs: Optional[List[Any]]
 177      standard_option_list: List[Option]
 178      usage: Optional[_Text]
 179      values: Optional[Values]
 180      version: _Text
 181      def __init__(
 182          self,
 183          usage: Optional[_Text] = ...,
 184          option_list: Iterable[Option] = ...,
 185          option_class: Type[Option] = ...,
 186          version: Optional[_Text] = ...,
 187          conflict_handler: _Text = ...,
 188          description: Optional[_Text] = ...,
 189          formatter: Optional[HelpFormatter] = ...,
 190          add_help_option: bool = ...,
 191          prog: Optional[_Text] = ...,
 192          epilog: Optional[_Text] = ...,
 193      ) -> None: ...
 194      def _add_help_option(self) -> None: ...
 195      def _add_version_option(self) -> None: ...
 196      def _create_option_list(self) -> None: ...
 197      def _get_all_options(self) -> List[Option]: ...
 198      def _get_args(self, args: Iterable[Any]) -> List[Any]: ...
 199      def _init_parsing_state(self) -> None: ...
 200      def _match_long_opt(self, opt: _Text) -> _Text: ...
 201      def _populate_option_list(self, option_list: Iterable[Option], add_help: bool = ...) -> None: ...
 202      def _process_args(self, largs: List[Any], rargs: List[Any], values: Values) -> None: ...
 203      def _process_long_opt(self, rargs: List[Any], values: Any) -> None: ...
 204      def _process_short_opts(self, rargs: List[Any], values: Any) -> None: ...
 205      @overload
 206      def add_option_group(self, __opt_group: OptionGroup) -> OptionParser: ...
 207      @overload
 208      def add_option_group(self, *args: Any, **kwargs: Any) -> OptionParser: ...
 209      def check_values(self, values: Values, args: List[_Text]) -> Tuple[Values, List[_Text]]: ...
 210      def disable_interspersed_args(self) -> None: ...
 211      def enable_interspersed_args(self) -> None: ...
 212      def error(self, msg: _Text) -> None: ...
 213      def exit(self, status: int = ..., msg: Optional[str] = ...) -> None: ...
 214      def expand_prog_name(self, s: Optional[_Text]) -> Any: ...
 215      def format_epilog(self, formatter: HelpFormatter) -> Any: ...
 216      def format_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ...
 217      def format_option_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ...
 218      def get_default_values(self) -> Values: ...
 219      def get_option_group(self, opt_str: _Text) -> Any: ...
 220      def get_prog_name(self) -> _Text: ...
 221      def get_usage(self) -> _Text: ...
 222      def get_version(self) -> _Text: ...
 223      def parse_args(
 224          self, args: Optional[Sequence[AnyStr]] = ..., values: Optional[Values] = ...
 225      ) -> Tuple[Values, List[AnyStr]]: ...
 226      def print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
 227      def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
 228      def print_version(self, file: Optional[IO[str]] = ...) -> None: ...
 229      def set_default(self, dest: Any, value: Any) -> None: ...
 230      def set_defaults(self, **kwargs: Any) -> None: ...
 231      def set_process_default_values(self, process: Any) -> None: ...
 232      def set_usage(self, usage: _Text) -> None: ...
 233