diff --git a/stubs/xlrd/METADATA.toml b/stubs/xlrd/METADATA.toml new file mode 100644 index 000000000000..d82f4f2f46c6 --- /dev/null +++ b/stubs/xlrd/METADATA.toml @@ -0,0 +1,2 @@ +version = "2.0.*" +upstream_repository = "https://github.com/python-excel/xlrd" diff --git a/stubs/xlrd/xlrd/__init__.pyi b/stubs/xlrd/xlrd/__init__.pyi new file mode 100644 index 000000000000..6c2738c15c24 --- /dev/null +++ b/stubs/xlrd/xlrd/__init__.pyi @@ -0,0 +1,41 @@ +import sys +from _typeshed import SupportsWrite +from typing import Final + +from . import timemachine as timemachine +from .biffh import ( + XL_CELL_BLANK as XL_CELL_BLANK, + XL_CELL_BOOLEAN as XL_CELL_BOOLEAN, + XL_CELL_DATE as XL_CELL_DATE, + XL_CELL_EMPTY as XL_CELL_EMPTY, + XL_CELL_ERROR as XL_CELL_ERROR, + XL_CELL_NUMBER as XL_CELL_NUMBER, + XL_CELL_TEXT as XL_CELL_TEXT, + biff_text_from_num as biff_text_from_num, + error_text_from_code as error_text_from_code, +) +from .book import Book as Book, colname as colname, open_workbook_xls as open_workbook_xls +from .formula import * +from .info import __VERSION__ as __VERSION__, __version__ as __version__ +from .sheet import empty_cell as empty_cell +from .xldate import XLDateError as XLDateError, xldate_as_datetime as xldate_as_datetime, xldate_as_tuple as xldate_as_tuple + +FILE_FORMAT_DESCRIPTIONS: Final[dict[str, str]] +ZIP_SIGNATURE: Final[bytes] +PEEK_SIZE: Final[int] + +def inspect_format(path: str | None = None, content: bytes | None = None) -> str | None: ... +def open_workbook( + filename: str | None = None, + logfile: SupportsWrite[str] = sys.stdout, + verbosity: int = 0, + use_mmap: bool = True, + file_contents: bytes | None = None, + encoding_override: str | None = None, + formatting_info: bool = False, + on_demand: bool = False, + ragged_rows: bool = False, + ignore_workbook_corruption: bool = False, +) -> Book: ... +def dump(filename: str, outfile: SupportsWrite[str] = sys.stdout, unnumbered: bool = False) -> None: ... +def count_records(filename: str, outfile: SupportsWrite[str] = sys.stdout) -> None: ... diff --git a/stubs/xlrd/xlrd/biffh.pyi b/stubs/xlrd/xlrd/biffh.pyi new file mode 100644 index 000000000000..73d01394464d --- /dev/null +++ b/stubs/xlrd/xlrd/biffh.pyi @@ -0,0 +1,176 @@ +import sys +from collections.abc import Callable +from typing import Any, Final, TextIO + +from .timemachine import * + +DEBUG: Final[int] + +class XLRDError(Exception): ... + +class BaseObject: + _repr_these: list[str] + def dump(self, f: TextIO | None = None, header: str | None = None, footer: str | None = None, indent: int = 0) -> None: ... + +FUN: Final[int] +FDT: Final[int] +FNU: Final[int] +FGE: Final[int] +FTX: Final[int] +DATEFORMAT: Final[int] +NUMBERFORMAT: Final[int] +XL_CELL_EMPTY: Final[int] +XL_CELL_TEXT: Final[int] +XL_CELL_NUMBER: Final[int] +XL_CELL_DATE: Final[int] +XL_CELL_BOOLEAN: Final[int] +XL_CELL_ERROR: Final[int] +XL_CELL_BLANK: Final[int] +biff_text_from_num: Final[dict[int, str]] +error_text_from_code: Final[dict[int, str]] +BIFF_FIRST_UNICODE: Final[int] +XL_WORKBOOK_GLOBALS: Final[int] +WBKBLOBAL: Final[int] +XL_WORKBOOK_GLOBALS_4W: Final[int] +XL_WORKSHEET: Final[int] +WRKSHEET: Final[int] +XL_BOUNDSHEET_WORKSHEET: Final[int] +XL_BOUNDSHEET_CHART: Final[int] +XL_BOUNDSHEET_VB_MODULE: Final[int] +XL_ARRAY: Final[int] +XL_ARRAY2: Final[int] +XL_BLANK: Final[int] +XL_BLANK_B2: Final[int] +XL_BOF: Final[int] +XL_BOOLERR: Final[int] +XL_BOOLERR_B2: Final[int] +XL_BOUNDSHEET: Final[int] +XL_BUILTINFMTCOUNT: Final[int] +XL_CF: Final[int] +XL_CODEPAGE: Final[int] +XL_COLINFO: Final[int] +XL_COLUMNDEFAULT: Final[int] +XL_COLWIDTH: Final[int] +XL_CONDFMT: Final[int] +XL_CONTINUE: Final[int] +XL_COUNTRY: Final[int] +XL_DATEMODE: Final[int] +XL_DEFAULTROWHEIGHT: Final[int] +XL_DEFCOLWIDTH: Final[int] +XL_DIMENSION: Final[int] +XL_DIMENSION2: Final[int] +XL_EFONT: Final[int] +XL_EOF: Final[int] +XL_EXTERNNAME: Final[int] +XL_EXTERNSHEET: Final[int] +XL_EXTSST: Final[int] +XL_FEAT11: Final[int] +XL_FILEPASS: Final[int] +XL_FONT: Final[int] +XL_FONT_B3B4: Final[int] +XL_FORMAT: Final[int] +XL_FORMAT2: Final[int] +XL_FORMULA: Final[int] +XL_FORMULA3: Final[int] +XL_FORMULA4: Final[int] +XL_GCW: Final[int] +XL_HLINK: Final[int] +XL_QUICKTIP: Final[int] +XL_HORIZONTALPAGEBREAKS: Final[int] +XL_INDEX: Final[int] +XL_INTEGER: Final[int] +XL_IXFE: Final[int] +XL_LABEL: Final[int] +XL_LABEL_B2: Final[int] +XL_LABELRANGES: Final[int] +XL_LABELSST: Final[int] +XL_LEFTMARGIN: Final[int] +XL_TOPMARGIN: Final[int] +XL_RIGHTMARGIN: Final[int] +XL_BOTTOMMARGIN: Final[int] +XL_HEADER: Final[int] +XL_FOOTER: Final[int] +XL_HCENTER: Final[int] +XL_VCENTER: Final[int] +XL_MERGEDCELLS: Final[int] +XL_MSO_DRAWING: Final[int] +XL_MSO_DRAWING_GROUP: Final[int] +XL_MSO_DRAWING_SELECTION: Final[int] +XL_MULRK: Final[int] +XL_MULBLANK: Final[int] +XL_NAME: Final[int] +XL_NOTE: Final[int] +XL_NUMBER: Final[int] +XL_NUMBER_B2: Final[int] +XL_OBJ: Final[int] +XL_PAGESETUP: Final[int] +XL_PALETTE: Final[int] +XL_PANE: Final[int] +XL_PRINTGRIDLINES: Final[int] +XL_PRINTHEADERS: Final[int] +XL_RK: Final[int] +XL_ROW: Final[int] +XL_ROW_B2: Final[int] +XL_RSTRING: Final[int] +XL_SCL: Final[int] +XL_SHEETHDR: Final[int] +XL_SHEETPR: Final[int] +XL_SHEETSOFFSET: Final[int] +XL_SHRFMLA: Final[int] +XL_SST: Final[int] +XL_STANDARDWIDTH: Final[int] +XL_STRING: Final[int] +XL_STRING_B2: Final[int] +XL_STYLE: Final[int] +XL_SUPBOOK: Final[int] +XL_TABLEOP: Final[int] +XL_TABLEOP2: Final[int] +XL_TABLEOP_B2: Final[int] +XL_TXO: Final[int] +XL_UNCALCED: Final[int] +XL_UNKNOWN: Final[int] +XL_VERTICALPAGEBREAKS: Final[int] +XL_WINDOW2: Final[int] +XL_WINDOW2_B2: Final[int] +XL_WRITEACCESS: Final[int] +XL_WSBOOL: Final[int] +XL_XF: Final[int] +XL_XF2: Final[int] +XL_XF3: Final[int] +XL_XF4: Final[int] +boflen: Final[dict[int, int]] +bofcodes: Final[tuple[int, int, int, int]] +XL_FORMULA_OPCODES: Final[tuple[int, int, int]] + +def is_cell_opcode(c: int) -> bool: ... +def upkbits( + tgt_obj: object, src: int, manifest: list[tuple[int, int, str]], local_setattr: Callable[[Any, str, Any], None] = ... +) -> None: ... +def upkbitsL( + tgt_obj: object, + src: int, + manifest: list[tuple[int, int, str]], + local_setattr: Callable[[Any, str, Any], None] = ..., + local_int: Callable[[Any], int] = ..., +) -> None: ... +def unpack_string(data: bytes, pos: int, encoding: str, lenlen: int = 1) -> str: ... +def unpack_string_update_pos( + data: bytes, pos: int, encoding: str, lenlen: int = 1, known_len: int | None = None +) -> tuple[str, int]: ... +def unpack_unicode(data: bytes, pos: int, lenlen: int = 2) -> str: ... +def unpack_unicode_update_pos(data: bytes, pos: int, lenlen: int = 2, known_len: int | None = None) -> tuple[str, int]: ... +def unpack_cell_range_address_list_update_pos( + output_list: list[tuple[int, int, int, int]], data: bytes, pos: int, biff_version: int, addr_size: int = 6 +) -> int: ... + +biff_rec_name_dict: Final[dict[int, str]] + +def hex_char_dump( + strg: bytes, ofs: int, dlen: int, base: int = 0, fout: TextIO = sys.stdout, unnumbered: bool = False +) -> None: ... +def biff_dump( + mem: bytes, stream_offset: int, stream_len: int, base: int = 0, fout: TextIO = sys.stdout, unnumbered: bool = False +) -> None: ... +def biff_count_records(mem: bytes, stream_offset: int, stream_len: int, fout: TextIO = sys.stdout) -> None: ... + +encoding_from_codepage: Final[dict[int, str]] diff --git a/stubs/xlrd/xlrd/book.pyi b/stubs/xlrd/xlrd/book.pyi new file mode 100644 index 000000000000..35819e83e79f --- /dev/null +++ b/stubs/xlrd/xlrd/book.pyi @@ -0,0 +1,151 @@ +import sys +from _typeshed import SupportsWrite +from collections.abc import Iterator +from types import TracebackType +from typing import Final, Literal +from typing_extensions import Self + +from .biffh import * +from .formatting import XF, Font, Format +from .formula import * +from .sheet import Cell, Sheet +from .timemachine import * + +empty_cell: Final[Cell] +MY_EOF: Final[int] +SUPBOOK_UNK: Final[int] +SUPBOOK_INTERNAL: Final[int] +SUPBOOK_EXTERNAL: Final[int] +SUPBOOK_ADDIN: Final[int] +SUPBOOK_DDEOLE: Final[int] +SUPPORTED_VERSIONS: Final[tuple[int, ...]] +builtin_name_from_code: Final[dict[str, str]] +code_from_builtin_name: Final[dict[str, str]] + +def open_workbook_xls( + filename: str | None = None, + logfile: SupportsWrite[str] = sys.stdout, + verbosity: int = 0, + use_mmap: bool = True, + file_contents: bytes | None = None, + encoding_override: str | None = None, + formatting_info: bool = False, + on_demand: bool = False, + ragged_rows: bool = False, + ignore_workbook_corruption: bool = False, +) -> Book: ... + +class Name(BaseObject): + _repr_these: list[str] + book: Book | None = None + hidden: Literal[0, 1] + func: Literal[0, 1] + vbasic: Literal[0, 1] + macro: Literal[0, 1] + complex: Literal[0, 1] + builtin: Literal[0, 1] + funcgroup: Literal[0, 1] + binary: Literal[0, 1] + name_index: int + name: str + raw_formula: bytes + scope: Literal[-1, -2, -3, 0] + result: Operand | None + def cell(self) -> Cell: ... + def area2d(self, clipped: bool = True) -> tuple[Sheet, int, int, int, int]: ... + +class Book(BaseObject): + nsheets: int + datemode: Literal[0, 1] + biff_version: int + name_obj_list: list[Name] + codepage: int | None + encoding: str | None + countries: tuple[int, int] + user_name: str + font_list: list[Font] + xf_list: list[XF] + format_list: list[Format] + format_map: dict[int, Format] + style_name_map: dict[str, tuple[int, int]] + colour_map: dict[int, tuple[int, int, int] | None] + palette_record: list[tuple[int, int, int]] + load_time_stage_1: float + load_time_stage_2: float + def sheets(self) -> list[Sheet]: ... + def sheet_by_index(self, sheetx: int) -> Sheet: ... + def __iter__(self) -> Iterator[Sheet]: ... + def sheet_by_name(self, sheet_name: str) -> Sheet: ... + def __getitem__(self, item: int | str) -> Sheet: ... + def sheet_names(self) -> list[str]: ... + def sheet_loaded(self, sheet_name_or_index: int | str) -> bool: ... + def unload_sheet(self, sheet_name_or_index: int | str) -> None: ... + mem: bytes | None = None + filestr: bytes | None = None + def release_resources(self) -> None: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + name_and_scope_map: dict[tuple[str, int], Name] + name_map: dict[str, list[Name]] + raw_user_name: bool + builtinfmtcount: int + addin_func_names: list[str] + def __init__(self) -> None: ... + logfile: SupportsWrite[str] + verbosity: int + use_mmap: bool + encoding_override: str | None + formatting_info: bool + on_demand: bool + ragged_rows: bool + stream_len: int + base: int + def biff2_8_load( + self, + filename: str | None = None, + file_contents: bytes | None = None, + logfile: SupportsWrite[str] = sys.stdout, + verbosity: int = 0, + use_mmap: bool = True, + encoding_override: str | None = None, + formatting_info: bool = False, + on_demand: bool = False, + ragged_rows: bool = False, + ignore_workbook_corruption: bool = False, + ) -> None: ... + xfcount: int + actualfmtcount: int + def initialise_format_info(self) -> None: ... + def get2bytes(self) -> int: ... + def get_record_parts(self) -> tuple[int, int, bytes]: ... + def get_record_parts_conditional(self, reqd_record: int) -> tuple[int | None, int, bytes]: ... + def get_sheet(self, sh_number: int, update_pos: bool = True) -> Sheet: ... + def get_sheets(self) -> None: ... + def fake_globals_get_sheet(self) -> None: ... + def handle_boundsheet(self, data: bytes) -> None: ... + def handle_builtinfmtcount(self, data: bytes) -> None: ... + def derive_encoding(self) -> str: ... + def handle_codepage(self, data: bytes) -> None: ... + def handle_country(self, data: bytes) -> None: ... + def handle_datemode(self, data: bytes) -> None: ... + def handle_externname(self, data: bytes) -> None: ... + def handle_externsheet(self, data: bytes) -> None: ... + def handle_filepass(self, data: bytes) -> None: ... + def handle_name(self, data: bytes) -> None: ... + def names_epilogue(self) -> None: ... + def handle_obj(self, data: bytes) -> None: ... + def handle_supbook(self, data: bytes) -> None: ... + def handle_sheethdr(self, data: bytes) -> None: ... + def handle_sheetsoffset(self, data: bytes) -> None: ... + def handle_sst(self, data: bytes) -> None: ... + def handle_writeaccess(self, data: bytes) -> None: ... + def parse_globals(self) -> None: ... + def read(self, pos: int, length: int) -> bytes: ... + def getbof(self, rqd_stream: int) -> int | None: ... + +# Helper functions +def expand_cell_address(inrow: int, incol: int) -> tuple[int, int, int, int]: ... +def display_cell_address(rowx: int, colx: int, relrow: int, relcol: int) -> str: ... +def unpack_SST_table(datatab: list[bytes], nstrings: int) -> tuple[list[str], dict[int, list[tuple[int, int]]]]: ... diff --git a/stubs/xlrd/xlrd/compdoc.pyi b/stubs/xlrd/xlrd/compdoc.pyi new file mode 100644 index 000000000000..aea4c94a3738 --- /dev/null +++ b/stubs/xlrd/xlrd/compdoc.pyi @@ -0,0 +1,54 @@ +import sys +from _typeshed import SupportsWrite +from typing import Final + +from .timemachine import * + +SIGNATURE: Final[bytes] +EOCSID: Final[int] +FREESID: Final[int] +SATSID: Final[int] +MSATSID: Final[int] +EVILSID: Final[int] + +class CompDocError(Exception): ... + +class DirNode: + DID: int + name: str + etype: int + colour: int + left_DID: int + right_DID: int + root_DID: int + first_SID: int + tot_size: int + children: list[int] + parent: int + tsinfo: tuple[int, int, int, int] + logfile: SupportsWrite[str] + def __init__(self, DID: int, dent: bytes, DEBUG: int = 0, logfile: SupportsWrite[str] = sys.stdout) -> None: ... + def dump(self, DEBUG: int = 1) -> None: ... + +class CompDoc: + logfile: SupportsWrite[str] + ignore_workbook_corruption: bool + DEBUG: int + mem: bytes + sec_size: int + short_sec_size: int + mem_data_secs: int + mem_data_len: int + seen: list[int] + SAT: list[int] + dirlist: list[DirNode] + SSCS: str + SSAT: list[int] + def __init__( + self, mem: bytes, logfile: SupportsWrite[str] = sys.stdout, DEBUG: int = 0, ignore_workbook_corruption: bool = False + ) -> None: ... + def get_named_stream(self, qname: str) -> bytes | None: ... + def locate_named_stream(self, qname: str) -> tuple[bytes | None, int, int]: ... + +def x_dump_line(alist: list[int], stride: int, f: SupportsWrite[str], dpos: int, equal: int = 0) -> None: ... +def dump_list(alist: list[int], stride: int, f: SupportsWrite[str] = sys.stdout) -> None: ... diff --git a/stubs/xlrd/xlrd/formatting.pyi b/stubs/xlrd/xlrd/formatting.pyi new file mode 100644 index 000000000000..a0898ca32dc4 --- /dev/null +++ b/stubs/xlrd/xlrd/formatting.pyi @@ -0,0 +1,111 @@ +from collections.abc import Callable +from typing import Final, Literal + +from .biffh import BaseObject +from .book import Book +from .timemachine import * + +DEBUG: Final[int] +excel_default_palette_b5: Final[tuple[tuple[int, int, int], ...]] +excel_default_palette_b2: Final[tuple[tuple[int, int, int], ...]] +excel_default_palette_b8: Final[tuple[tuple[int, int, int], ...]] +default_palette: Final[dict[int, tuple[tuple[int, int, int], ...]]] +built_in_style_names: Final[list[str]] + +def initialise_colour_map(book: Book) -> None: ... +def nearest_colour_index( + colour_map: dict[int, tuple[int, int, int] | None], rgb: tuple[int, int, int] | None, debug: int = 0 +) -> int: ... + +class EqNeAttrs: + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + +class Font(BaseObject, EqNeAttrs): + bold: Literal[0, 1] + character_set: int + colour_index: int + escapement: Literal[0, 1, 2] + family: Literal[0, 1, 2, 3, 4, 5] + font_index: int + height: int + italic: Literal[0, 1] + name: str + struck_out: Literal[0, 1] + underline_type: Literal[0, 1, 33, 34] + underlined: Literal[0, 1] + weight: int + outline: Literal[0, 1] + shadow: Literal[0, 1] + +def handle_efont(book: Book, data: bytes) -> None: ... +def handle_font(book: Book, data: bytes) -> None: ... + +class Format(BaseObject, EqNeAttrs): + format_key: int + type: int + format_str: str + def __init__(self, format_key: int, ty: int, format_str: str) -> None: ... + +std_format_strings: dict[int, str] +fmt_code_ranges: list[tuple[int, int, int]] +std_format_code_types: dict[int, int] +date_char_dict: dict[str, Literal[5]] +skip_char_dict: dict[str, Literal[1]] +num_char_dict: dict[str, Literal[5]] +non_date_formats: dict[str, Literal[1]] +fmt_bracketed_sub: Callable[[str, str], str] + +def is_date_format_string(book: Book, fmt: str) -> bool: ... +def handle_format(self: Book, data: bytes, rectype: int = 1054) -> None: ... +def handle_palette(book: Book, data: bytes) -> None: ... +def palette_epilogue(book: Book) -> None: ... +def handle_style(book: Book, data: bytes) -> None: ... +def check_colour_indexes_in_obj(book: Book, obj: object, orig_index: int) -> None: ... +def fill_in_standard_formats(book: Book) -> None: ... +def handle_xf(self: Book, data: bytes) -> None: ... +def xf_epilogue(self: Book) -> None: ... +def initialise_book(book: Book) -> None: ... + +class XFBorder(BaseObject, EqNeAttrs): + top_colour_index: int + bottom_colour_index: int + left_colour_index: int + right_colour_index: int + diag_colour_index: int + top_line_style: int + bottom_line_style: int + left_line_style: int + right_line_style: int + diag_line_style: int + diag_down: Literal[0, 1] + diag_up: Literal[0, 1] + +class XFBackground(BaseObject, EqNeAttrs): + fill_pattern: int + background_colour_index: int + pattern_colour_index: int + +class XFAlignment(BaseObject, EqNeAttrs): + hor_align: int + vert_align: int + rotation: int + text_wrapped: Literal[0, 1] + indent_level: int + shrink_to_fit: Literal[0, 1] + text_direction: Literal[0, 1, 2] + +class XFProtection(BaseObject, EqNeAttrs): + cell_locked: Literal[0, 1] + formula_hidden: Literal[0, 1] + +class XF(BaseObject): + is_style: Literal[0, 1] + parent_style_index: int + xf_index: int + font_index: int + format_key: int + protection: XFProtection | None + background: XFBackground | None + alignment: XFAlignment | None + border: XFBorder | None diff --git a/stubs/xlrd/xlrd/formula.pyi b/stubs/xlrd/xlrd/formula.pyi new file mode 100644 index 000000000000..4ed7928003cf --- /dev/null +++ b/stubs/xlrd/xlrd/formula.pyi @@ -0,0 +1,87 @@ +from typing import Final +from typing_extensions import Self + +from .book import Book, Name +from .timemachine import * + +__all__ = [ + "oBOOL", + "oERR", + "oNUM", + "oREF", + "oREL", + "oSTRG", + "oUNK", + "decompile_formula", + "dump_formula", + "evaluate_name_formula", + "okind_dict", + "rangename3d", + "rangename3drel", + "cellname", + "cellnameabs", + "colname", + "FMLA_TYPE_CELL", + "FMLA_TYPE_SHARED", + "FMLA_TYPE_ARRAY", + "FMLA_TYPE_COND_FMT", + "FMLA_TYPE_DATA_VAL", + "FMLA_TYPE_NAME", + "Operand", + "Ref3D", +] + +FMLA_TYPE_CELL: Final[int] +FMLA_TYPE_SHARED: Final[int] +FMLA_TYPE_ARRAY: Final[int] +FMLA_TYPE_COND_FMT: Final[int] +FMLA_TYPE_DATA_VAL: Final[int] +FMLA_TYPE_NAME: Final[int] +oBOOL: Final[int] +oERR: Final[int] +oNUM: Final[int] +oREF: Final[int] +oREL: Final[int] +oSTRG: Final[int] +oUNK: Final[int] +okind_dict: Final[dict[int, str]] + +class FormulaError(Exception): ... + +class Operand: + value: float | str | None + kind: int + text: str + rank: int + def __init__(self, akind: int | None = None, avalue: float | str | None = None, arank: int = 0, atext: str = "?") -> None: ... + +class Ref3D(tuple[int, int, int, int, int, int, int, int, int, int, int, int]): + coords: tuple[int, int, int, int, int, int] + relflags: tuple[int, int, int, int, int, int] + shtxlo: int + shtxhi: int + rowxlo: int + rowxhi: int + colxlo: int + colxhi: int + def __new__(cls, atuple: tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> Self: ... + def __init__(self, atuple: tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ... + +def evaluate_name_formula(bk: Book, nobj: Name, namex: str, blah: int = 0, level: int = 0) -> None: ... +def decompile_formula( + bk: Book, + fmla: bytes, + fmlalen: int, + fmlatype: int | None = None, + browx: int | None = None, + bcolx: int | None = None, + blah: int = 0, + level: int = 0, + r1c1: int = 0, +) -> str | None: ... +def dump_formula(bk: Book, data: bytes, fmlalen: int, bv: int, reldelta: int, blah: int = 0, isname: int = 0) -> None: ... +def cellname(rowx: int, colx: int) -> str: ... +def cellnameabs(rowx: int, colx: int, r1c1: int = 0) -> str: ... +def colname(colx: int) -> str: ... +def rangename3d(book: Book, ref3d: Ref3D) -> str: ... +def rangename3drel(book: Book, ref3d: Ref3D, browx: int | None = None, bcolx: int | None = None, r1c1: int = 0) -> str: ... diff --git a/stubs/xlrd/xlrd/info.pyi b/stubs/xlrd/xlrd/info.pyi new file mode 100644 index 000000000000..e0737403b5b0 --- /dev/null +++ b/stubs/xlrd/xlrd/info.pyi @@ -0,0 +1,4 @@ +from typing import Final + +__version__: Final[str] +__VERSION__: Final[str] diff --git a/stubs/xlrd/xlrd/sheet.pyi b/stubs/xlrd/xlrd/sheet.pyi new file mode 100644 index 000000000000..9d6193654642 --- /dev/null +++ b/stubs/xlrd/xlrd/sheet.pyi @@ -0,0 +1,163 @@ +from _typeshed import SupportsWrite +from array import array +from collections.abc import Callable, Sequence +from typing import Any, Final, Literal, overload + +from .biffh import * +from .book import Book +from .formatting import XF +from .timemachine import * + +OBJ_MSO_DEBUG: Final[int] + +class MSODrawing(BaseObject): ... +class MSObj(BaseObject): ... +class MSTxo(BaseObject): ... + +class Note(BaseObject): + author: str + col_hidden: int + colx: int + rich_text_runlist: list[tuple[str, int]] | None + row_hidden: int + rowx: int + show: int + text: str + +class Hyperlink(BaseObject): + frowx: int | None + lrowx: int | None + fcolx: int | None + lcolx: int | None + type: str | None + url_or_path: bytes | str | None + desc: str | None + target: str | None + textmark: str | None + quicktip: str | None + +def unpack_RK(rk_str: bytes) -> float: ... + +cellty_from_fmtty: Final[dict[int, int]] +ctype_text: Final[dict[int, str]] + +class Cell(BaseObject): + ctype: int + value: str + xf_index: int | None + def __init__(self, ctype: int, value: str, xf_index: int | None = None) -> None: ... + +empty_cell: Final[Cell] + +class Colinfo(BaseObject): + width: int + xf_index: int + hidden: int + bit1_flag: int + outline_level: int + collapsed: int + +class Rowinfo(BaseObject): + height: int | None + has_default_height: int | None + outline_level: int | None + outline_group_starts_ends: int | None + hidden: int | None + height_mismatch: int | None + has_default_xf_index: int | None + xf_index: int | None + additional_space_above: int | None + additional_space_below: int | None + def __init__(self) -> None: ... + def __getstate__(self) -> tuple[int | None, ...]: ... + def __setstate__(self, state: tuple[int | None, ...]) -> None: ... + +class Sheet(BaseObject): + name: str + book: Book | None + nrows: int + ncols: int + colinfo_map: dict[int, Colinfo] + rowinfo_map: dict[int, Rowinfo] + col_label_ranges: list[tuple[int, int, int, int]] + row_label_ranges: list[tuple[int, int, int, int]] + merged_cells: list[tuple[int, int, int, int]] + rich_text_runlist_map: dict[tuple[int, int], list[tuple[int, int]]] + defcolwidth: float | None + standardwidth: float | None + default_row_height: int | None + default_row_height_mismatch: int | None + default_row_hidden: int | None + default_additional_space_above: int | None + default_additional_space_below: int | None + visibility: Literal[0, 1, 2] + gcw: tuple[int, ...] + hyperlink_list: list[Hyperlink] + hyperlink_map: dict[tuple[int, int], Hyperlink] + cell_note_map: dict[tuple[int, int], Note] + vert_split_pos: int + horz_split_pos: int + horz_split_first_visible: int + vert_split_first_visible: int + split_active_pane: int + has_pane_record: int + horizontal_page_breaks: list[tuple[int, int, int]] + vertical_page_breaks: list[tuple[int, int, int]] + biff_version: int + logfile: SupportsWrite[str] + bt: array[int] + bf: array[int] + number: int + verbosity: int + formatting_info: bool + ragged_rows: bool + put_cell: Callable[[int, int, int | None, str, int | None], None] + first_visible_rowx: int + first_visible_colx: int + gridline_colour_index: int + gridline_colour_rgb: tuple[int, int, int] | None + cooked_page_break_preview_mag_factor: int + cooked_normal_view_mag_factor: int + cached_page_break_preview_mag_factor: int + cached_normal_view_mag_factor: int + scl_mag_factor: int | None + utter_max_rows: int + utter_max_cols: int + def __init__(self, book: Book, position: int, name: str, number: int) -> None: ... + def cell(self, rowx: int, colx: int) -> Cell: ... + def cell_value(self, rowx: int, colx: int) -> str: ... + def cell_type(self, rowx: int, colx: int) -> int: ... + def cell_xf_index(self, rowx: int, colx: int) -> int: ... + def row_len(self, rowx: int) -> int: ... + def row(self, rowx: int) -> list[Cell]: ... + @overload + def __getitem__(self, item: int) -> list[Cell]: ... + @overload + def __getitem__(self, item: tuple[int, int]) -> Cell: ... + def get_rows(self) -> tuple[list[Cell], ...]: ... + __iter__ = get_rows + def row_types(self, rowx: int, start_colx: int = 0, end_colx: int | None = None) -> Sequence[int]: ... + def row_values(self, rowx: int, start_colx: int = 0, end_colx: int | None = None) -> Sequence[str]: ... + def row_slice(self, rowx: int, start_colx: int = 0, end_colx: int | None = None) -> list[Cell]: ... + def col_slice(self, colx: int, start_rowx: int = 0, end_rowx: int | None = None) -> list[Cell]: ... + def col_values(self, colx: int, start_rowx: int = 0, end_rowx: int | None = None) -> list[str]: ... + def col_types(self, colx: int, start_rowx: int = 0, end_rowx: int | None = None) -> list[int]: ... + col = col_slice + def tidy_dimensions(self) -> None: ... + def put_cell_ragged(self, rowx: int, colx: int, ctype: int | None, value: str, xf_index: int | None) -> None: ... + def put_cell_unragged(self, rowx: int, colx: int, ctype: int | None, value: str, xf_index: int | None) -> None: ... + def read(self, bk: Book) -> Literal[1]: ... + def string_record_contents(self, data: bytes) -> str | None: ... + def update_cooked_mag_factors(self) -> None: ... + def fixed_BIFF2_xfindex(self, cell_attr: bytes, rowx: int, colx: int, true_xfx: int | None = None) -> int: ... + def insert_new_BIFF20_xf(self, cell_attr: bytes, style: int = 0) -> int: ... + def fake_XF_from_BIFF20_cell_attr(self, cell_attr: bytes, style: int = 0) -> XF: ... + def req_fmt_info(self) -> None: ... + def computed_column_width(self, colx: int) -> float: ... + def handle_hlink(self, data: bytes) -> None: ... + def handle_quicktip(self, data: bytes) -> None: ... + def handle_msodrawingetc(self, recid: Any, data_len: int, data: bytes) -> None: ... + def handle_obj(self, data: bytes) -> MSObj | None: ... + def handle_note(self, data: bytes, txos: dict[int, MSTxo]) -> None: ... + def handle_txo(self, data: bytes) -> MSTxo | None: ... + def handle_feat11(self, data: bytes) -> None: ... diff --git a/stubs/xlrd/xlrd/timemachine.pyi b/stubs/xlrd/xlrd/timemachine.pyi new file mode 100644 index 000000000000..1a44b9bce94c --- /dev/null +++ b/stubs/xlrd/xlrd/timemachine.pyi @@ -0,0 +1,19 @@ +from collections.abc import Callable +from io import BytesIO +from typing import Any + +python_version: tuple[int, int] + +BYTES_LITERAL: Callable[[str], bytes] +UNICODE_LITERAL: Callable[[str], str] +BYTES_ORD: Callable[[bytes], int] +BYTES_IO: type[BytesIO] + +def fprintf(f: Any, fmt: str, *vargs: Any) -> None: ... + +EXCEL_TEXT_TYPES: tuple[type[str], type[bytes], type[bytearray]] +REPR = ascii +xrange = range +unicode: Callable[[bytes, str], str] +ensure_unicode: Callable[[str | bytes], str] +unichr = chr diff --git a/stubs/xlrd/xlrd/xldate.pyi b/stubs/xlrd/xlrd/xldate.pyi new file mode 100644 index 000000000000..7940d5c20707 --- /dev/null +++ b/stubs/xlrd/xlrd/xldate.pyi @@ -0,0 +1,24 @@ +import datetime +from typing import Final, Literal + +_JDN_delta: Final[tuple[int, int]] +epoch_1904: Final[datetime.datetime] +epoch_1900: Final[datetime.datetime] +epoch_1900_minus_1: Final[datetime.datetime] +_XLDAYS_TOO_LARGE: Final[tuple[int, int]] +_days_in_month: Final[tuple[None, int, int, int, int, int, int, int, int, int, int, int, int]] + +class XLDateError(ValueError): ... +class XLDateNegative(XLDateError): ... +class XLDateAmbiguous(XLDateError): ... +class XLDateTooLarge(XLDateError): ... +class XLDateBadDatemode(XLDateError): ... +class XLDateBadTuple(XLDateError): ... + +# 0: 1900-based, 1: 1904-based. +def xldate_as_tuple(xldate: float, datemode: Literal[0, 1]) -> tuple[int, int, int, int, int, int]: ... +def xldate_as_datetime(xldate: float, datemode: Literal[0, 1]) -> datetime.datetime: ... +def _leap(y: int) -> Literal[0, 1]: ... +def xldate_from_date_tuple(date_tuple: tuple[int, int, int], datemode: Literal[0, 1]) -> float: ... +def xldate_from_time_tuple(time_tuple: tuple[int, int, int]) -> float: ... +def xldate_from_datetime_tuple(datetime_tuple: tuple[int, int, int, int, int, int], datemode: Literal[0, 1]) -> float: ...