From 19eade5e4458b86fa2696df37666f684c353052a Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 22 Apr 2020 14:02:19 -0400 Subject: [PATCH] Add msilib and _msi (#3651) --- stdlib/2and3/_msi.pyi | 62 ++++++++++++++ stdlib/2and3/msilib/__init__.pyi | 134 +++++++++++++++++++++++++++++++ stdlib/2and3/msilib/schema.pyi | 96 ++++++++++++++++++++++ stdlib/2and3/msilib/sequence.pyi | 15 ++++ stdlib/2and3/msilib/text.pyi | 10 +++ 5 files changed, 317 insertions(+) create mode 100644 stdlib/2and3/_msi.pyi create mode 100644 stdlib/2and3/msilib/__init__.pyi create mode 100644 stdlib/2and3/msilib/schema.pyi create mode 100644 stdlib/2and3/msilib/sequence.pyi create mode 100644 stdlib/2and3/msilib/text.pyi diff --git a/stdlib/2and3/_msi.pyi b/stdlib/2and3/_msi.pyi new file mode 100644 index 000000000..092edf993 --- /dev/null +++ b/stdlib/2and3/_msi.pyi @@ -0,0 +1,62 @@ + +import sys +from typing import List, Optional, Union + +if sys.platform == 'win32': + + # Actual typename View, not exposed by the implementation + class _View: + + def Execute(self, params: Optional[_Record] = ...) -> None: ... + def GetColumnInfo(self, kind: int) -> _Record: ... + def Fetch(self) -> _Record: ... + def Modify(self, mode: int, record: _Record) -> None: ... + def Close(self) -> None: ... + + # Don't exist at runtime + __new__: None # type: ignore + __init__: None # type: ignore + + # Actual typename Summary, not exposed by the implementation + class _Summary: + + def GetProperty(self, propid: int) -> Optional[Union[str, bytes]]: ... + def GetPropertyCount(self) -> int: ... + def SetProperty(self, propid: int, value: Union[str, bytes]) -> None: ... + def Persist(self) -> None: ... + + # Don't exist at runtime + __new__: None # type: ignore + __init__: None # type: ignore + + # Actual typename Database, not exposed by the implementation + class _Database: + + def OpenView(self, sql: str) -> _View: ... + def Commit(self) -> None: ... + def GetSummaryInformation(self, updateCount: int) -> _Summary: ... + def Close(self) -> None: ... + + # Don't exist at runtime + __new__: None # type: ignore + __init__: None # type: ignore + + # Actual typename Record, not exposed by the implementation + class _Record: + + def GetFieldCount(self) -> int: ... + def GetInteger(self, field: int) -> int: ... + def GetString(self, field: int) -> str: ... + def SetString(self, field: int, str: str) -> None: ... + def SetStream(self, field: int, stream: str) -> None: ... + def SetInteger(self, field: int, int: int) -> None: ... + def ClearData(self) -> None: ... + + # Don't exist at runtime + __new__: None # type: ignore + __init__: None # type: ignore + + def UuidCreate() -> str: ... + def FCICreate(cabname: str, files: List[str]) -> None: ... + def OpenDatabase(name: str, flags: int) -> _Database: ... + def CreateRecord(count: int) -> _Record: ... diff --git a/stdlib/2and3/msilib/__init__.pyi b/stdlib/2and3/msilib/__init__.pyi new file mode 100644 index 000000000..b61b7d642 --- /dev/null +++ b/stdlib/2and3/msilib/__init__.pyi @@ -0,0 +1,134 @@ + +import sys +from typing import List, Tuple, Union, Set, Optional, Dict, Container, Any, Type, Iterable, Sequence +from types import ModuleType + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +if sys.platform == 'win32': + from _msi import _Database + + AMD64: bool + if sys.version_info < (3, 7): + Itanium: bool + Win64: bool + + datasizemask: Literal[0x00ff] + type_valid: Literal[0x0100] + type_localizable: Literal[0x0200] + typemask: Literal[0x0c00] + type_long: Literal[0x0000] + type_short: Literal[0x0400] + type_string: Literal[0x0c00] + type_binary: Literal[0x0800] + type_nullable: Literal[0x1000] + type_key: Literal[0x2000] + knownbits: Literal[0x3fff] + + class Table: + + name: str + fields: List[Tuple[int, str, int]] + + def __init__(self, name: str) -> None: ... + def add_field(self, index: int, name: str, type: int) -> None: ... + def sql(self) -> str: ... + def create(self, db: _Database) -> None: ... + + class _Unspecified: ... + + def change_sequence(seq: Sequence[Tuple[str, Optional[str], int]], action: str, seqno: Union[int, Type[_Unspecified]] = ..., cond: Union[str, Type[_Unspecified]] = ...) -> None: ... + def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ... + def add_stream(db: _Database, name: str, path: str) -> None: ... + def init_database(name: str, schema: ModuleType, ProductName: str, ProductCode: str, ProductVersion: str, Manufacturer: str) -> _Database: ... + def add_tables(db: _Database, module: ModuleType) -> None: ... + def make_id(str: str) -> str: ... + def gen_uuid() -> str: ... + + class CAB: + + name: str + files: List[Tuple[str, str]] + filenames: Set[str] + index: int + + def __init__(self, name: str) -> None: ... + def gen_id(self, file: str) -> str: ... + def append(self, full: str, file: str, logical: str) -> Tuple[int, str]: ... + def commit(self, db: _Database) -> None: ... + + _directories: Set[str] + + class Directory: + + db: _Database + cab: CAB + basedir: str + physical: str + logical: str + component: Optional[str] + short_names: Set[str] + ids: Set[str] + keyfiles: Dict[str, str] + componentflags: Optional[int] + absolute: str + + def __init__(self, db: _Database, cab: CAB, basedir: str, physical: str, _logical: str, default: str, componentflags: Optional[int] = ...) -> None: ... + def start_component(self, component: Optional[str] = ..., feature: Optional[Feature] = ..., flags: Optional[int] = ..., keyfile: Optional[str] = ..., uuid: Optional[str] = ...) -> None: ... + def make_short(self, file: str) -> str: ... + def add_file(self, file: str, src: Optional[str] = ..., version: Optional[str] = ..., language: Optional[str] = ...) -> str: ... + def glob(self, pattern: str, exclude: Optional[Container[str]] = ...) -> List[str]: ... + def remove_pyc(self) -> None: ... + + class Binary: + + name: str + + def __init__(self, fname: str) -> None: ... + def __repr__(self) -> str: ... + + class Feature: + + id: str + + def __init__(self, db: _Database, id: str, title: str, desc: str, display: int, level: int = ..., parent: Optional[Feature] = ..., directory: Optional[str] = ..., attributes: int = ...) -> None: ... + def set_current(self) -> None: ... + + class Control: + + dlg: Dialog + name: str + + def __init__(self, dlg: Dialog, name: str) -> None: ... + def event(self, event: str, argument: str, condition: str = ..., ordering: Optional[int] = ...) -> None: ... + def mapping(self, event: str, attribute: str) -> None: ... + def condition(self, action: str, condition: str) -> None: ... + + class RadioButtonGroup(Control): + + property: str + index: int + + def __init__(self, dlg: Dialog, name: str, property: str) -> None: ... + def add(self, name: str, x: int, y: int, w: int, h: int, text: str, value: Optional[str] = ...) -> None: ... + + class Dialog: + + db: _Database + name: str + x: int + y: int + w: int + h: int + + def __init__(self, db: _Database, name: str, x: int, y: int, w: int, h: int, attr: int, title: str, first: str, default: str, cancel: str) -> None: ... + def control(self, name: str, type: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str], help: Optional[str]) -> Control: ... + def text(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str]) -> Control: ... + def bitmap(self, name: str, x: int, y: int, w: int, h: int, text: Optional[str]) -> Control: ... + def line(self, name: str, x: int, y: int, w: int, h: int) -> Control: ... + def pushbutton(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str], next: Optional[str]) -> Control: ... + def radiogroup(self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str]) -> RadioButtonGroup: ... + def checkbox(self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str]) -> Control: ... diff --git a/stdlib/2and3/msilib/schema.pyi b/stdlib/2and3/msilib/schema.pyi new file mode 100644 index 000000000..251e1ea39 --- /dev/null +++ b/stdlib/2and3/msilib/schema.pyi @@ -0,0 +1,96 @@ + +import sys +from typing import List, Tuple, Optional + +if sys.platform == 'win32': + from . import Table + + _Validation: Table + ActionText: Table + AdminExecuteSequence: Table + Condition: Table + AdminUISequence: Table + AdvtExecuteSequence: Table + AdvtUISequence: Table + AppId: Table + AppSearch: Table + Property: Table + BBControl: Table + Billboard: Table + Feature: Table + Binary: Table + BindImage: Table + File: Table + CCPSearch: Table + CheckBox: Table + Class: Table + Component: Table + Icon: Table + ProgId: Table + ComboBox: Table + CompLocator: Table + Complus: Table + Directory: Table + Control: Table + Dialog: Table + ControlCondition: Table + ControlEvent: Table + CreateFolder: Table + CustomAction: Table + DrLocator: Table + DuplicateFile: Table + Environment: Table + Error: Table + EventMapping: Table + Extension: Table + MIME: Table + FeatureComponents: Table + FileSFPCatalog: Table + SFPCatalog: Table + Font: Table + IniFile: Table + IniLocator: Table + InstallExecuteSequence: Table + InstallUISequence: Table + IsolatedComponent: Table + LaunchCondition: Table + ListBox: Table + ListView: Table + LockPermissions: Table + Media: Table + MoveFile: Table + MsiAssembly: Table + MsiAssemblyName: Table + MsiDigitalCertificate: Table + MsiDigitalSignature: Table + MsiFileHash: Table + MsiPatchHeaders: Table + ODBCAttribute: Table + ODBCDriver: Table + ODBCDataSource: Table + ODBCSourceAttribute: Table + ODBCTranslator: Table + Patch: Table + PatchPackage: Table + PublishComponent: Table + RadioButton: Table + Registry: Table + RegLocator: Table + RemoveFile: Table + RemoveIniFile: Table + RemoveRegistry: Table + ReserveCost: Table + SelfReg: Table + ServiceControl: Table + ServiceInstall: Table + Shortcut: Table + Signature: Table + TextStyle: Table + TypeLib: Table + UIText: Table + Upgrade: Table + Verb: Table + + tables: List[Table] + + _Validation_records: List[Tuple[str, str, str, Optional[int], Optional[int], Optional[str], Optional[int], Optional[str], Optional[str], str]] diff --git a/stdlib/2and3/msilib/sequence.pyi b/stdlib/2and3/msilib/sequence.pyi new file mode 100644 index 000000000..4f75d0dd3 --- /dev/null +++ b/stdlib/2and3/msilib/sequence.pyi @@ -0,0 +1,15 @@ + +import sys +from typing import List, Tuple, Optional + +if sys.platform == 'win32': + + _SequenceType = List[Tuple[str, Optional[str], int]] + + AdminExecuteSequence: _SequenceType + AdminUISequence: _SequenceType + AdvtExecuteSequence: _SequenceType + InstallExecuteSequence: _SequenceType + InstallUISequence: _SequenceType + + tables: List[str] diff --git a/stdlib/2and3/msilib/text.pyi b/stdlib/2and3/msilib/text.pyi new file mode 100644 index 000000000..c27aebb52 --- /dev/null +++ b/stdlib/2and3/msilib/text.pyi @@ -0,0 +1,10 @@ + +import sys +from typing import List, Tuple, Optional + +if sys.platform == 'win32': + + ActionText: List[Tuple[str, str, Optional[str]]] + UIText: List[Tuple[str, Optional[str]]] + + tables: List[str]