mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Add stubs for "click-web" package (#13208)
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
"stubs/caldav",
|
||||
"stubs/cffi",
|
||||
"stubs/click-default-group",
|
||||
"stubs/click-web",
|
||||
"stubs/commonmark",
|
||||
"stubs/corus",
|
||||
"stubs/dateparser",
|
||||
|
||||
3
stubs/click-web/METADATA.toml
Normal file
3
stubs/click-web/METADATA.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
version = "0.8.*"
|
||||
requires = ["click>=8.0.0", "Flask>=2.3.2"]
|
||||
upstream_repository = "https://github.com/fredrik-corneliusson/click-web"
|
||||
16
stubs/click-web/click_web/__init__.pyi
Normal file
16
stubs/click-web/click_web/__init__.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
import logging
|
||||
import types
|
||||
from _typeshed import Incomplete
|
||||
|
||||
import click
|
||||
import flask
|
||||
|
||||
# This should be jinja2.Environment, but it does not have stubs and forbidden for requires in METADATA.toml
|
||||
jinja_env: Incomplete
|
||||
script_file: str | None
|
||||
click_root_cmd: str | None
|
||||
OUTPUT_FOLDER: str
|
||||
_flask_app: flask.Flask | None
|
||||
logger: logging.Logger | None
|
||||
|
||||
def create_click_web_app(module: types.ModuleType, command: click.BaseCommand, root: str = "/") -> flask.Flask: ...
|
||||
2
stubs/click-web/click_web/exceptions.pyi
Normal file
2
stubs/click-web/click_web/exceptions.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
class ClickWebException(Exception): ...
|
||||
class CommandNotFound(ClickWebException): ...
|
||||
79
stubs/click-web/click_web/resources/cmd_exec.pyi
Normal file
79
stubs/click-web/click_web/resources/cmd_exec.pyi
Normal file
@@ -0,0 +1,79 @@
|
||||
import logging
|
||||
|
||||
from flask import Response
|
||||
|
||||
from .input_fields import FieldId
|
||||
|
||||
logger: logging.Logger | None
|
||||
|
||||
HTML_HEAD: str
|
||||
HTML_TAIL: str
|
||||
|
||||
class Executor:
|
||||
RAW_CMD_PATH: str
|
||||
|
||||
def __init__(self) -> None: ...
|
||||
def exec(self, command_path: str) -> Response: ...
|
||||
def _exec_raw(self, command: list[str]) -> Response: ... # undocumented
|
||||
def _exec_html(self, command_path: str) -> Response: ... # undocumented
|
||||
def _run_script_and_generate_stream(self) -> None: ... # undocumented
|
||||
def _create_cmd_header(self, commands: list[CmdPart]) -> str: ... # undocumented
|
||||
def _create_result_footer(self) -> str: ... # undocumented
|
||||
|
||||
def _get_download_link(field_info: FieldFileInfo) -> str: ... # undocumented
|
||||
|
||||
class CommandLineRaw:
|
||||
def __init__(self, script_file_path: str, command: str) -> None: ...
|
||||
def append(self, part: str, secret: bool = False) -> None: ...
|
||||
def get_commandline(self, obfuscate: bool = False) -> list[str]: ...
|
||||
def get_download_field_infos(self) -> list[FieldInfo]: ...
|
||||
def after_script_executed(self) -> None: ...
|
||||
|
||||
class CommandLineForm:
|
||||
def __init__(self, script_file_path: str, commands: list[str]) -> None: ...
|
||||
def append(self, part: str, secret: bool = False) -> None: ...
|
||||
def get_commandline(self, obfuscate: bool = False) -> list[str]: ...
|
||||
def get_download_field_infos(self) -> list[FieldInfo]: ...
|
||||
def after_script_executed(self) -> None: ...
|
||||
|
||||
def _get_python_interpreter() -> str: ...
|
||||
|
||||
class CmdPart:
|
||||
def __init__(self, part: str, secret: bool = False) -> None: ...
|
||||
|
||||
class FormToCommandLineBuilder:
|
||||
def __init__(self, command_line: CommandLineForm) -> None: ...
|
||||
def add_command_args(self, command_index: int) -> None: ...
|
||||
@staticmethod
|
||||
def _is_option(cmd_option: str) -> bool: ...
|
||||
def _process_option(self, field_info: FieldInfo) -> None: ...
|
||||
|
||||
class FieldInfo:
|
||||
@staticmethod
|
||||
def factory(key: str) -> FieldInfo: ...
|
||||
def __init__(self, param: FieldId) -> None: ...
|
||||
def before_script_execute(self) -> None: ...
|
||||
def after_script_executed(self) -> None: ...
|
||||
def __lt__(self, other: object) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class FieldFileInfo(FieldInfo):
|
||||
def __init__(self, fimeta: FieldId) -> None: ...
|
||||
def before_script_execute(self) -> None: ...
|
||||
@classmethod
|
||||
def temp_dir(cls) -> str: ...
|
||||
def save(self) -> None: ...
|
||||
|
||||
class FieldOutFileInfo(FieldFileInfo):
|
||||
def __init__(self, fimeta: FieldId) -> None: ...
|
||||
def save(self) -> None: ...
|
||||
|
||||
class FieldPathInfo(FieldFileInfo):
|
||||
def save(self) -> None: ...
|
||||
def after_script_executed(self) -> None: ...
|
||||
|
||||
class FieldPathOutInfo(FieldOutFileInfo):
|
||||
def save(self) -> None: ...
|
||||
def after_script_executed(self) -> None: ...
|
||||
|
||||
def zip_folder(folder_path: str, out_folder: str, out_prefix: str) -> str: ...
|
||||
6
stubs/click-web/click_web/resources/cmd_form.pyi
Normal file
6
stubs/click-web/click_web/resources/cmd_form.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
import click
|
||||
|
||||
def get_form_for(command_path: str) -> str: ...
|
||||
def _get_commands_by_path(command_path: str) -> list[tuple[click.Context, click.Command]]: ...
|
||||
def _generate_form_data(ctx_and_commands: list[tuple[click.Context, click.Command]]): ...
|
||||
def _process_help(help_text: bool) -> str: ...
|
||||
6
stubs/click-web/click_web/resources/index.pyi
Normal file
6
stubs/click-web/click_web/resources/index.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
import click
|
||||
|
||||
def index() -> str: ...
|
||||
def _click_to_tree(ctx: click.Context, node: click.Command, ancestors: list[click.Command] | None = None) -> dict[str, Any]: ...
|
||||
49
stubs/click-web/click_web/resources/input_fields.pyi
Normal file
49
stubs/click-web/click_web/resources/input_fields.pyi
Normal file
@@ -0,0 +1,49 @@
|
||||
from typing import Any
|
||||
|
||||
import click
|
||||
|
||||
class FieldId:
|
||||
SEPARATOR: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
command_index: int,
|
||||
param_index: int,
|
||||
param_type: str,
|
||||
click_type: str,
|
||||
nargs: int,
|
||||
form_type: str,
|
||||
name: str,
|
||||
key: str | None = None,
|
||||
): ...
|
||||
@classmethod
|
||||
def from_string(cls, field_info_as_string: str) -> FieldId: ...
|
||||
|
||||
class NotSupported(ValueError): ...
|
||||
|
||||
class BaseInput:
|
||||
param_type_cls: type | None
|
||||
def __init__(self, ctx: click.Context, param: click.Parameter, command_index: int, param_index: int) -> None: ...
|
||||
def is_supported(self) -> bool: ...
|
||||
@property
|
||||
def fields(self) -> dict[str, Any]: ...
|
||||
@property
|
||||
def type_attrs(self) -> dict[str, Any]: ...
|
||||
def _to_cmd_line_name(self, name: str) -> str: ...
|
||||
def _build_name(self, name: str): ...
|
||||
|
||||
class ChoiceInput(BaseInput): ...
|
||||
class FlagInput(BaseInput): ...
|
||||
class IntInput(BaseInput): ...
|
||||
class FloatInput(BaseInput): ...
|
||||
class FolderInput(BaseInput): ...
|
||||
class FileInput(BaseInput): ...
|
||||
class EmailInput(BaseInput): ...
|
||||
class PasswordInput(BaseInput): ...
|
||||
class TextAreaInput(BaseInput): ...
|
||||
class DefaultInput(BaseInput): ...
|
||||
|
||||
INPUT_TYPES: list[type]
|
||||
_DEFAULT_INPUT: list[type]
|
||||
|
||||
def get_input_field(ctx: click.Context, param: click.Parameter, command_index, param_index) -> dict[str, Any]: ...
|
||||
18
stubs/click-web/click_web/web_click_types.pyi
Normal file
18
stubs/click-web/click_web/web_click_types.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
import re
|
||||
import typing as t
|
||||
|
||||
import click
|
||||
|
||||
class EmailParamType(click.ParamType):
|
||||
EMAIL_REGEX: re.Pattern[str]
|
||||
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
|
||||
|
||||
class PasswordParamType(click.ParamType):
|
||||
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
|
||||
|
||||
class TextAreaParamType(click.ParamType):
|
||||
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
|
||||
|
||||
EMAIL_TYPE: EmailParamType
|
||||
PASSWORD_TYPE: PasswordParamType
|
||||
TEXTAREA_TYPE: TextAreaParamType
|
||||
Reference in New Issue
Block a user