mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Add pyxdg stubs (#10163)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
"stubs/python-dateutil",
|
||||
"stubs/python-jose",
|
||||
"stubs/pywin32",
|
||||
"stubs/pyxdg",
|
||||
"stubs/PyYAML",
|
||||
"stubs/qrcode",
|
||||
"stubs/redis",
|
||||
|
||||
2
stubs/pyxdg/@tests/stubtest_allowlist.txt
Normal file
2
stubs/pyxdg/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
xdg.IconTheme.basedir # This is a side-effect of a for loop rather than an intended part of the API.
|
||||
xdg.DesktopEntry.DesktopEntry.checkCategorie # Exists for backwards compatibility.
|
||||
279
stubs/pyxdg/@tests/test_cases/check_IniFile.py
Normal file
279
stubs/pyxdg/@tests/test_cases/check_IniFile.py
Normal file
@@ -0,0 +1,279 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import List, Tuple
|
||||
from typing_extensions import assert_type
|
||||
|
||||
from xdg.IniFile import IniFile
|
||||
|
||||
# The "get" method is quite complex with many overloads. Check that many forms
|
||||
# are valid.
|
||||
# The function definition is:
|
||||
# def get(self, key, group=None, locale=False, type="string", list=False, strict=False):
|
||||
|
||||
# Get str
|
||||
assert_type(IniFile().get("some_key"), str)
|
||||
assert_type(IniFile().get("some_key", None), str)
|
||||
assert_type(IniFile().get("some_key", "group"), str)
|
||||
assert_type(IniFile().get("some_key", "group", False), str)
|
||||
assert_type(IniFile().get("some_key", "group", True), str)
|
||||
assert_type(IniFile().get("some_key", "group", True, "string"), str)
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", False), str)
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", False, False), str)
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", False, True), str)
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", group=None), str)
|
||||
assert_type(IniFile().get("some_key", group="group"), str)
|
||||
assert_type(IniFile().get("some_key", locale=False), str)
|
||||
assert_type(IniFile().get("some_key", locale=True), str)
|
||||
assert_type(IniFile().get("some_key", strict=False), str)
|
||||
assert_type(IniFile().get("some_key", strict=True), str)
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True), str)
|
||||
# Explicitly set type as string in keyword parameters.
|
||||
assert_type(IniFile().get("some_key", type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group=None, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group="group", type="string"), str)
|
||||
assert_type(IniFile().get("some_key", locale=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", locale=True, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", strict=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", strict=True, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True, type="string"), str)
|
||||
# Explicitly set list.
|
||||
assert_type(IniFile().get("some_key", list=False), str)
|
||||
assert_type(IniFile().get("some_key", group=None, list=False), str)
|
||||
assert_type(IniFile().get("some_key", group="group", list=False), str)
|
||||
assert_type(IniFile().get("some_key", locale=False, list=False), str)
|
||||
assert_type(IniFile().get("some_key", locale=True, list=False), str)
|
||||
assert_type(IniFile().get("some_key", strict=False, list=False), str)
|
||||
assert_type(IniFile().get("some_key", strict=True, list=False), str)
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True, list=False), str)
|
||||
# Explicitly set both.
|
||||
assert_type(IniFile().get("some_key", list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group=None, list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group="group", list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", locale=False, list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", locale=True, list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", strict=False, list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", strict=True, list=False, type="string"), str)
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True, list=False, type="string"), str)
|
||||
|
||||
# Get List[str]
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", True), List[str])
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", True, False), List[str])
|
||||
assert_type(IniFile().get("some_key", "group", True, "string", True, True), List[str])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", list=True, group=None), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, group="group"), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, locale=False), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, locale=True), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, strict=False), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, strict=True), List[str])
|
||||
assert_type(IniFile().get("some_key", list=True, group="group", locale=True, strict=True), List[str])
|
||||
# Explicitly set list
|
||||
assert_type(IniFile().get("some_key", list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", group=None, list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", group="group", list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", locale=False, list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", locale=True, list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", strict=False, list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", strict=True, list=True), List[str])
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True, list=True), List[str])
|
||||
# Explicitly set both
|
||||
assert_type(IniFile().get("some_key", list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", group=None, list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", group="group", list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", locale=False, list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", locale=True, list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", strict=False, list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", strict=True, list=True, type="string"), List[str])
|
||||
assert_type(IniFile().get("some_key", group="group", locale=True, strict=True, list=True, type="string"), List[str])
|
||||
|
||||
# Get bool
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean"), bool)
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", False), bool)
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", False, False), bool)
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", False, True), bool)
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="boolean"), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group=None), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group="group"), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", locale=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", locale=True), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", strict=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", strict=True), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group="group", locale=True, strict=True), bool)
|
||||
# Explicitly set list
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group=None, list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group="group", list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", locale=False, list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", locale=True, list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", strict=False, list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", strict=True, list=False), bool)
|
||||
assert_type(IniFile().get("some_key", type="boolean", group="group", locale=True, strict=True, list=False), bool)
|
||||
|
||||
# Get List[bool]
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", True), List[bool])
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", True, False), List[bool])
|
||||
assert_type(IniFile().get("some_key", "group", True, "boolean", True, True), List[bool])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, group=None), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, group="group"), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, locale=False), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, locale=True), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, strict=False), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, strict=True), List[bool])
|
||||
assert_type(IniFile().get("some_key", type="boolean", list=True, group="group", locale=True, strict=True), List[bool])
|
||||
|
||||
# Get int
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer"), int)
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", False), int)
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", False, False), int)
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", False, True), int)
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="integer"), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group=None), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group="group"), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", locale=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", locale=True), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", strict=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", strict=True), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group="group", locale=True, strict=True), int)
|
||||
# Explicitly set list.
|
||||
assert_type(IniFile().get("some_key", type="integer", list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group=None, list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group="group", list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", locale=False, list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", locale=True, list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", strict=False, list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", strict=True, list=False), int)
|
||||
assert_type(IniFile().get("some_key", type="integer", group="group", locale=True, strict=True, list=False), int)
|
||||
|
||||
# Get List[int]
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", True), List[int])
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", True, False), List[int])
|
||||
assert_type(IniFile().get("some_key", "group", True, "integer", True, True), List[int])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, group=None), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, group="group"), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, locale=False), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, locale=True), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, strict=False), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, strict=True), List[int])
|
||||
assert_type(IniFile().get("some_key", type="integer", list=True, group="group", locale=True, strict=True), List[int])
|
||||
|
||||
# Get float
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric"), float)
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", False), float)
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", False, False), float)
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", False, True), float)
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="numeric"), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group=None), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group="group"), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", locale=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", locale=True), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", strict=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", strict=True), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group="group", locale=True, strict=True), float)
|
||||
# Explicitly set list.
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group=None, list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group="group", list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", locale=False, list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", locale=True, list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", strict=False, list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", strict=True, list=False), float)
|
||||
assert_type(IniFile().get("some_key", type="numeric", group="group", locale=True, strict=True, list=False), float)
|
||||
|
||||
# Get List[float]
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", True), List[float])
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", True, False), List[float])
|
||||
assert_type(IniFile().get("some_key", "group", True, "numeric", True, True), List[float])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, group=None), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, group="group"), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, locale=False), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, locale=True), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, strict=False), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, strict=True), List[float])
|
||||
assert_type(IniFile().get("some_key", type="numeric", list=True, group="group", locale=True, strict=True), List[float])
|
||||
|
||||
# Get regex
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex"), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", False, False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", False, True), re.Pattern[str])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="regex"), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group=None), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group="group"), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", locale=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", locale=True), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", strict=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", strict=True), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group="group", locale=True, strict=True), re.Pattern[str])
|
||||
# Explicitly set list.
|
||||
assert_type(IniFile().get("some_key", type="regex", list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group=None, list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group="group", list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", locale=False, list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", locale=True, list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", strict=False, list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", strict=True, list=False), re.Pattern[str])
|
||||
assert_type(IniFile().get("some_key", type="regex", group="group", locale=True, strict=True, list=False), re.Pattern[str])
|
||||
|
||||
# Get List[regex]
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", True), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", True, False), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", "group", True, "regex", True, True), List[re.Pattern[str]])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, group=None), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, group="group"), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, locale=False), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, locale=True), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, strict=False), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, strict=True), List[re.Pattern[str]])
|
||||
assert_type(IniFile().get("some_key", type="regex", list=True, group="group", locale=True, strict=True), List[re.Pattern[str]])
|
||||
|
||||
# Get point
|
||||
assert_type(IniFile().get("some_key", "group", True, "point"), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", False, False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", False, True), Tuple[int, int])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="point"), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group=None), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group="group"), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", locale=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", locale=True), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", strict=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", strict=True), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group="group", locale=True, strict=True), Tuple[int, int])
|
||||
# Explicitly set list.
|
||||
assert_type(IniFile().get("some_key", type="point", list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group=None, list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group="group", list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", locale=False, list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", locale=True, list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", strict=False, list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", strict=True, list=False), Tuple[int, int])
|
||||
assert_type(IniFile().get("some_key", type="point", group="group", locale=True, strict=True, list=False), Tuple[int, int])
|
||||
|
||||
# Get List[point]
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", True), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", True, False), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", "group", True, "point", True, True), List[Tuple[int, int]])
|
||||
# Keyword parameters
|
||||
assert_type(IniFile().get("some_key", type="point", list=True), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, group=None), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, group="group"), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, locale=False), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, locale=True), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, strict=False), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, strict=True), List[Tuple[int, int]])
|
||||
assert_type(IniFile().get("some_key", type="point", list=True, group="group", locale=True, strict=True), List[Tuple[int, int]])
|
||||
2
stubs/pyxdg/METADATA.toml
Normal file
2
stubs/pyxdg/METADATA.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "0.28.*"
|
||||
upstream_repository = "https://github.com/takluyver/pyxdg"
|
||||
18
stubs/pyxdg/xdg/BaseDirectory.pyi
Normal file
18
stubs/pyxdg/xdg/BaseDirectory.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Iterator
|
||||
|
||||
xdg_data_home: str
|
||||
xdg_data_dirs: list[str]
|
||||
xdg_config_home: str
|
||||
xdg_config_dirs: list[str]
|
||||
xdg_cache_home: str
|
||||
xdg_state_home: str
|
||||
|
||||
def save_config_path(*resource: StrPath) -> str: ...
|
||||
def save_data_path(*resource: StrPath) -> str: ...
|
||||
def save_cache_path(*resource: StrPath) -> str: ...
|
||||
def save_state_path(*resource: StrPath) -> str: ...
|
||||
def load_config_paths(*resource: StrPath) -> Iterator[str]: ...
|
||||
def load_first_config(*resource: StrPath) -> str: ...
|
||||
def load_data_paths(*resource: StrPath) -> Iterator[str]: ...
|
||||
def get_runtime_dir(strict: bool = True) -> str: ...
|
||||
13
stubs/pyxdg/xdg/Config.pyi
Normal file
13
stubs/pyxdg/xdg/Config.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
language: str
|
||||
windowmanager: str | None
|
||||
icon_theme: str
|
||||
icon_size: int
|
||||
cache_time: int
|
||||
root_mode: bool
|
||||
|
||||
def setWindowManager(wm: str) -> None: ...
|
||||
def setIconTheme(theme: str) -> None: ...
|
||||
def setIconSize(size: int) -> None: ...
|
||||
def setCacheTime(time: int) -> None: ...
|
||||
def setLocale(lang: str) -> None: ...
|
||||
def setRootMode(boolean: bool) -> None: ...
|
||||
65
stubs/pyxdg/xdg/DesktopEntry.pyi
Normal file
65
stubs/pyxdg/xdg/DesktopEntry.pyi
Normal file
@@ -0,0 +1,65 @@
|
||||
import re
|
||||
from _typeshed import StrPath
|
||||
from typing_extensions import Literal
|
||||
|
||||
from xdg.IniFile import IniFile
|
||||
|
||||
class DesktopEntry(IniFile):
|
||||
defaultGroup: str
|
||||
content: dict[str, dict[str, str]]
|
||||
def __init__(self, filename: StrPath | None = None) -> None: ...
|
||||
def parse(self, file: StrPath) -> None: ... # type: ignore[override]
|
||||
def findTryExec(self) -> str | None: ...
|
||||
def getType(self) -> str: ...
|
||||
def getVersion(self) -> float: ...
|
||||
def getVersionString(self) -> str: ...
|
||||
def getName(self) -> str: ...
|
||||
def getGenericName(self) -> str: ...
|
||||
def getNoDisplay(self) -> bool: ...
|
||||
def getComment(self) -> str: ...
|
||||
def getIcon(self) -> str: ...
|
||||
def getHidden(self) -> bool: ...
|
||||
def getOnlyShowIn(self) -> list[str]: ...
|
||||
def getNotShowIn(self) -> list[str]: ...
|
||||
def getTryExec(self) -> str: ...
|
||||
def getExec(self) -> str: ...
|
||||
def getPath(self) -> str: ...
|
||||
def getTerminal(self) -> bool: ...
|
||||
def getMimeType(self) -> list[re.Pattern[str]]: ...
|
||||
def getMimeTypes(self) -> list[str]: ...
|
||||
def getCategories(self) -> list[str]: ...
|
||||
def getStartupNotify(self) -> bool: ...
|
||||
def getStartupWMClass(self) -> str: ...
|
||||
def getURL(self) -> str: ...
|
||||
def getServiceTypes(self) -> list[str]: ...
|
||||
def getDocPath(self) -> str: ...
|
||||
def getKeywords(self) -> list[str]: ...
|
||||
def getInitialPreference(self) -> str: ...
|
||||
def getDev(self) -> str: ...
|
||||
def getFSType(self) -> str: ...
|
||||
def getMountPoint(self) -> str: ...
|
||||
def getReadonly(self) -> bool: ...
|
||||
def getUnmountIcon(self) -> str: ...
|
||||
def getMiniIcon(self) -> str: ...
|
||||
def getTerminalOptions(self) -> str: ...
|
||||
def getDefaultApp(self) -> str: ...
|
||||
def getProtocols(self) -> list[str]: ...
|
||||
def getExtensions(self) -> list[str]: ...
|
||||
def getBinaryPattern(self) -> str: ...
|
||||
def getMapNotify(self) -> str: ...
|
||||
def getEncoding(self) -> str: ...
|
||||
def getSwallowTitle(self) -> str: ...
|
||||
def getSwallowExec(self) -> str: ...
|
||||
def getSortOrder(self) -> list[str]: ...
|
||||
def getFilePattern(self) -> re.Pattern[str]: ...
|
||||
def getActions(self) -> list[str]: ...
|
||||
filename: str
|
||||
def new(self, filename: str) -> None: ...
|
||||
type: Literal["Application", "Directory"]
|
||||
name: str
|
||||
def checkExtras(self) -> None: ...
|
||||
def checkGroup(self, group: str) -> None: ...
|
||||
def checkKey(self, key: str, value: str, group: str) -> None: ...
|
||||
def checkType(self, key: str, type: str) -> None: ...
|
||||
def checkOnlyShowIn(self, value: str) -> None: ...
|
||||
def checkCategories(self, value: str) -> None: ...
|
||||
41
stubs/pyxdg/xdg/Exceptions.pyi
Normal file
41
stubs/pyxdg/xdg/Exceptions.pyi
Normal file
@@ -0,0 +1,41 @@
|
||||
debug: bool
|
||||
|
||||
class Error(Exception):
|
||||
msg: str
|
||||
def __init__(self, msg: str) -> None: ...
|
||||
|
||||
class ValidationError(Error):
|
||||
msg: str
|
||||
file: str
|
||||
def __init__(self, msg: str, file: str) -> None: ...
|
||||
|
||||
class ParsingError(Error):
|
||||
msg: str
|
||||
file: str
|
||||
def __init__(self, msg: str, file: str) -> None: ...
|
||||
|
||||
class NoKeyError(Error):
|
||||
key: str
|
||||
group: str
|
||||
file: str
|
||||
def __init__(self, key: str, group: str, file: str) -> None: ...
|
||||
|
||||
class DuplicateKeyError(Error):
|
||||
key: str
|
||||
group: str
|
||||
file: str
|
||||
def __init__(self, key: str, group: str, file: str) -> None: ...
|
||||
|
||||
class NoGroupError(Error):
|
||||
group: str
|
||||
file: str
|
||||
def __init__(self, group: str, file: str) -> None: ...
|
||||
|
||||
class DuplicateGroupError(Error):
|
||||
group: str
|
||||
file: str
|
||||
def __init__(self, group: str, file: str) -> None: ...
|
||||
|
||||
class NoThemeError(Error):
|
||||
theme: str
|
||||
def __init__(self, theme: str) -> None: ...
|
||||
55
stubs/pyxdg/xdg/IconTheme.pyi
Normal file
55
stubs/pyxdg/xdg/IconTheme.pyi
Normal file
@@ -0,0 +1,55 @@
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Collection
|
||||
|
||||
from xdg.IniFile import IniFile
|
||||
|
||||
class IconTheme(IniFile):
|
||||
def __init__(self) -> None: ...
|
||||
dir: str
|
||||
name: str
|
||||
comment: str
|
||||
directories: list[str]
|
||||
type: str
|
||||
def parse(self, file: StrPath) -> None: ... # type: ignore[override]
|
||||
def getDir(self) -> str: ...
|
||||
def getName(self) -> str: ...
|
||||
def getComment(self) -> str: ...
|
||||
def getInherits(self) -> list[str]: ...
|
||||
def getDirectories(self) -> list[str]: ...
|
||||
def getScaledDirectories(self) -> list[str]: ...
|
||||
def getHidden(self) -> bool: ...
|
||||
def getExample(self) -> str: ...
|
||||
def getSize(self, directory: StrPath) -> int: ...
|
||||
def getContext(self, directory: StrPath) -> str: ...
|
||||
def getType(self, directory: StrPath) -> str: ...
|
||||
def getMaxSize(self, directory: StrPath) -> int: ...
|
||||
def getMinSize(self, directory: StrPath) -> int: ...
|
||||
def getThreshold(self, directory: StrPath) -> int: ...
|
||||
def getScale(self, directory: StrPath) -> int: ...
|
||||
def checkExtras(self) -> None: ...
|
||||
def checkGroup(self, group: str) -> None: ...
|
||||
def checkKey(self, key: str, value: str, group: str) -> None: ...
|
||||
|
||||
class IconData(IniFile):
|
||||
def __init__(self) -> None: ...
|
||||
def parse(self, file: StrPath) -> None: ... # type: ignore[override]
|
||||
def getDisplayName(self) -> str: ...
|
||||
def getEmbeddedTextRectangle(self) -> list[int]: ...
|
||||
def getAttachPoints(self) -> list[tuple[int, int]]: ...
|
||||
def checkExtras(self) -> None: ...
|
||||
def checkGroup(self, group: str) -> None: ...
|
||||
def checkKey(self, key: str, value: str, group: str) -> None: ...
|
||||
|
||||
icondirs: list[str]
|
||||
themes: list[IconTheme]
|
||||
theme_cache: dict[str, IconTheme]
|
||||
dir_cache: dict[str, tuple[str, float, float]]
|
||||
icon_cache: dict[tuple[str, int, str, tuple[str, ...]], tuple[float, str]]
|
||||
|
||||
def getIconPath(
|
||||
iconname: str, size: int | None = None, theme: str | None = None, extensions: Collection[str] = ["png", "svg", "xpm"]
|
||||
) -> str: ...
|
||||
def getIconData(path: str) -> IconData: ...
|
||||
def LookupIcon(iconname: str, size: int, theme: str, extensions: Collection[str]) -> str: ...
|
||||
def DirectoryMatchesSize(subdir: str, iconsize: int, theme: str) -> bool: ...
|
||||
def DirectorySizeDistance(subdir: str, iconsize: int, theme: str) -> int: ...
|
||||
255
stubs/pyxdg/xdg/IniFile.pyi
Normal file
255
stubs/pyxdg/xdg/IniFile.pyi
Normal file
@@ -0,0 +1,255 @@
|
||||
import re
|
||||
from collections.abc import Iterable, KeysView
|
||||
from typing import overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
def is_ascii(s: str) -> bool: ...
|
||||
|
||||
class IniFile:
|
||||
defaultGroup: str
|
||||
fileExtension: str
|
||||
filename: str
|
||||
tainted: bool
|
||||
content: dict[str, dict[str, str]]
|
||||
warnings: list[str]
|
||||
errors: list[str]
|
||||
def __init__(self, filename: str | None = None) -> None: ...
|
||||
def __cmp__(self, other: IniFile) -> bool: ...
|
||||
def parse(self, filename: str, headers: Iterable[str] | None = None) -> None: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
type: Literal["string"] = "string",
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["string"], list: Literal[True], strict: bool = False
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
type: Literal["string"] = "string",
|
||||
strict: bool = False,
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None,
|
||||
locale: bool,
|
||||
type: Literal["boolean"],
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> bool: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["boolean"],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> bool: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["boolean"], list: Literal[True], strict: bool = False
|
||||
) -> list[bool]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["boolean"],
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
strict: bool = False,
|
||||
) -> list[bool]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None,
|
||||
locale: bool,
|
||||
type: Literal["integer"],
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> int: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["integer"],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> int: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["integer"], list: Literal[True], strict: bool = False
|
||||
) -> list[int]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["integer"],
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
strict: bool = False,
|
||||
) -> list[int]: ...
|
||||
|
||||
# Float
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None,
|
||||
locale: bool,
|
||||
type: Literal["numeric"],
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> float: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["numeric"],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> float: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["numeric"], list: Literal[True], strict: bool = False
|
||||
) -> list[float]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["numeric"],
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
strict: bool = False,
|
||||
) -> list[float]: ...
|
||||
|
||||
# Regex
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None,
|
||||
locale: bool,
|
||||
type: Literal["regex"],
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> re.Pattern[str]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["regex"],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> re.Pattern[str]: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["regex"], list: Literal[True], strict: bool = False
|
||||
) -> list[re.Pattern[str]]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["regex"],
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
strict: bool = False,
|
||||
) -> list[re.Pattern[str]]: ...
|
||||
# point
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
group: str | None,
|
||||
locale: bool,
|
||||
type: Literal["point"],
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> tuple[int, int]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["point"],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
list: Literal[False] = False,
|
||||
strict: bool = False,
|
||||
) -> tuple[int, int]: ...
|
||||
@overload
|
||||
def get(
|
||||
self, key: str, group: str | None, locale: bool, type: Literal["point"], list: Literal[True], strict: bool = False
|
||||
) -> list[tuple[int, int]]: ...
|
||||
@overload
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
*,
|
||||
type: Literal["point"],
|
||||
list: Literal[True],
|
||||
group: str | None = None,
|
||||
locale: bool = False,
|
||||
strict: bool = False,
|
||||
) -> list[tuple[int, int]]: ...
|
||||
def getList(self, string: str) -> list[str]: ...
|
||||
def validate(self, report: Literal["All", "Warnings", "Errors"] = "All") -> None: ...
|
||||
def checkGroup(self, group: str) -> None: ...
|
||||
def checkKey(self, key: str, value: str, group: str) -> None: ...
|
||||
def checkValue(
|
||||
self,
|
||||
key: str,
|
||||
value: str,
|
||||
type: Literal["string", "localestring", "boolean", "numeric", "integer", "regex", "point"] = "string",
|
||||
list: bool = False,
|
||||
) -> None: ...
|
||||
def checkExtras(self) -> None: ...
|
||||
def checkBoolean(self, value: str) -> Literal[1, 2, None]: ...
|
||||
def checkNumber(self, value: str) -> Literal[1, 2, None]: ...
|
||||
def checkInteger(self, value: str) -> Literal[1, None]: ...
|
||||
def checkPoint(self, value: str) -> Literal[1, None]: ...
|
||||
def checkString(self, value: str) -> Literal[0, 1]: ...
|
||||
def checkRegex(self, value: str) -> Literal[1, None]: ...
|
||||
def write(self, filename: str | None = None, trusted: bool = False) -> None: ...
|
||||
def set(self, key: str, value: str, group: str | None = None, locale: bool = False) -> None: ...
|
||||
def addGroup(self, group: str) -> None: ...
|
||||
def removeGroup(self, group: str) -> bool: ...
|
||||
def removeKey(self, key: str, group: str | None = None, locales: bool = True) -> str: ...
|
||||
def groups(self) -> KeysView[str]: ...
|
||||
def hasGroup(self, group: str) -> bool: ...
|
||||
def hasKey(self, key: str, group: str | None = None) -> bool: ...
|
||||
def getFileName(self) -> str: ...
|
||||
8
stubs/pyxdg/xdg/Locale.pyi
Normal file
8
stubs/pyxdg/xdg/Locale.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from collections.abc import Iterable
|
||||
|
||||
regex: str
|
||||
|
||||
def expand_languages(languages: Iterable[str] | None = None) -> list[str]: ...
|
||||
def update(language: str | None = None) -> None: ...
|
||||
|
||||
langs: list[str]
|
||||
167
stubs/pyxdg/xdg/Menu.pyi
Normal file
167
stubs/pyxdg/xdg/Menu.pyi
Normal file
@@ -0,0 +1,167 @@
|
||||
import ast
|
||||
import xml.dom
|
||||
from _typeshed import Unused
|
||||
from collections.abc import Collection, Iterable, Iterator
|
||||
from types import CodeType
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .DesktopEntry import DesktopEntry
|
||||
|
||||
DELETED: Literal["Deleted"] = "Deleted"
|
||||
NO_DISPLAY: Literal["NoDisplay"] = "NoDisplay"
|
||||
HIDDEN: Literal["Hidden"] = "Hidden"
|
||||
EMPTY: Literal["Empty"] = "Empty"
|
||||
NOT_SHOW_IN: Literal["NotShowIn"] = "NotShowIn"
|
||||
NO_EXEC: Literal["NoExec"] = "NoExec"
|
||||
|
||||
class Menu:
|
||||
Name: str
|
||||
Directory: Menu | None
|
||||
Entries: list[str]
|
||||
Doc: str
|
||||
Filename: str
|
||||
Depth: int
|
||||
Parent: Menu | None
|
||||
NotInXml: bool
|
||||
Show: bool
|
||||
Visible: int
|
||||
AppDirs: list[str]
|
||||
DefaultLayout: str | None
|
||||
Deleted: bool | None
|
||||
Directories: list[str]
|
||||
DirectoryDirs: list[Menu]
|
||||
Layout: Layout
|
||||
MenuEntries: list[MenuEntry | Menu | Separator]
|
||||
Moves: list[Move]
|
||||
OnlyUnallocated: bool | None
|
||||
Rules: list[Rule]
|
||||
Submenus: list[Menu]
|
||||
def __init__(self) -> None: ...
|
||||
def __add__(self, other: Menu) -> Menu: ...
|
||||
def __cmp__(self, other: Menu) -> int: ...
|
||||
def __lt__(self, other: object) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def getEntries(self, show_hidden: bool = False) -> Iterator[str]: ...
|
||||
def getMenuEntry(self, desktopfileid: int, deep: bool = False) -> MenuEntry: ...
|
||||
def getMenu(self, path: str) -> Menu: ...
|
||||
def getPath(self, org: bool = False, toplevel: bool = False) -> str: ...
|
||||
def getName(self) -> str: ...
|
||||
def getGenericName(self) -> str: ...
|
||||
def getComment(self) -> str: ...
|
||||
def getIcon(self) -> str: ...
|
||||
def sort(self) -> None: ...
|
||||
def addSubmenu(self, newmenu: Menu) -> None: ...
|
||||
def merge_inline(self, submenu: Menu) -> None: ...
|
||||
|
||||
class Move:
|
||||
Old: str
|
||||
New: str
|
||||
def __init__(self, old: str = "", new: str = "") -> None: ...
|
||||
def __cmp__(self, other: Move) -> int: ...
|
||||
|
||||
class Layout:
|
||||
show_empty: bool
|
||||
inline: bool
|
||||
inline_limit: int
|
||||
inline_header: bool
|
||||
inline_alias: bool
|
||||
def __init__(
|
||||
self,
|
||||
show_empty: bool = False,
|
||||
inline: bool = False,
|
||||
inline_limit: int = 4,
|
||||
inline_header: bool = True,
|
||||
inline_alias: bool = False,
|
||||
) -> None: ...
|
||||
@property
|
||||
def order(self) -> list[list[str]]: ...
|
||||
@order.setter
|
||||
def order(self, order: list[list[str]]) -> None: ...
|
||||
|
||||
class Rule:
|
||||
TYPE_INCLUDE: Literal[0]
|
||||
TYPE_EXCLUDE: Literal[1]
|
||||
@classmethod
|
||||
def fromFilename(cls, type: Literal[0, 1], filename: str) -> Rule: ...
|
||||
Type: Literal[0, 1]
|
||||
expression: ast.Expression
|
||||
code: CodeType
|
||||
def __init__(self, type: Literal[0, 1], expression: str) -> None: ...
|
||||
def apply(self, menuentries: Iterable[MenuEntry], run: int) -> Iterable[MenuEntry]: ...
|
||||
|
||||
class MenuEntry:
|
||||
TYPE_USER: Literal["User"]
|
||||
TYPE_SYSTEM: Literal["System"]
|
||||
TYPE_BOTH: Literal["Both"]
|
||||
DesktopEntry: DesktopEntry
|
||||
Show: Literal[True, False, "Deleted", "NoDisplay", "Hidden", "Empty", "NotShowIn", "NoExec"]
|
||||
Visible: Literal[1, 0, "Deleted", "NoDisplay", "Hidden", "Empty", "NotShowIn", "NoExec"]
|
||||
Original: MenuEntry | None
|
||||
Parents: list[Menu]
|
||||
Allocated: bool
|
||||
Add: bool
|
||||
MatchedInclude: bool
|
||||
Categories: list[str]
|
||||
def __init__(self, filename: str, dir: str = "", prefix: str = "") -> None: ...
|
||||
def save(self) -> None: ...
|
||||
def getDir(self) -> str: ...
|
||||
def getType(self) -> Literal["User", "System", "Both"]: ...
|
||||
Filename: str
|
||||
Prefix: str
|
||||
DesktopFileID: str
|
||||
def setAttributes(self, filename: str, dir: str = "", prefix: str = "") -> None: ...
|
||||
def updateAttributes(self) -> None: ...
|
||||
def __cmp__(self, other: MenuEntry) -> int: ...
|
||||
def __lt__(self, other: MenuEntry) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
class Separator:
|
||||
Parent: Menu
|
||||
Show: bool
|
||||
def __init__(self, parent: Menu) -> None: ...
|
||||
|
||||
class Header:
|
||||
Name: str
|
||||
GenericName: str
|
||||
Comment: str
|
||||
def __init__(self, name: str, generic_name: str, comment: str) -> None: ...
|
||||
|
||||
TYPE_DIR: Literal[0] = 0
|
||||
TYPE_FILE: Literal[1] = 1
|
||||
|
||||
class XMLMenuBuilder:
|
||||
debug: bool
|
||||
def __init__(self, debug: bool = False) -> None: ...
|
||||
cache: MenuEntryCache
|
||||
def parse(self, filename: str | None = None) -> Menu: ...
|
||||
def parse_menu(self, node: xml.dom.Node, filename: str) -> Menu: ...
|
||||
def parse_node(self, node: xml.dom.Node, filename: str, parent: Menu | None = None) -> None: ...
|
||||
def parse_layout(self, node: xml.dom.Node) -> Layout: ...
|
||||
def parse_move(self, node: xml.dom.Node) -> Move: ...
|
||||
def parse_rule(self, node: xml.dom.Node) -> Rule: ...
|
||||
def parse_bool_op(self, node: xml.dom.Node, operator: ast.And | ast.Or) -> ast.BoolOp | ast.UnaryOp | ast.Compare | None: ...
|
||||
def parse_rule_node(self, node: xml.dom.Node) -> ast.BoolOp | ast.UnaryOp | ast.Compare | None: ...
|
||||
def parse_app_dir(self, value: str, filename: str, parent: str) -> None: ...
|
||||
def parse_default_app_dir(self, filename: str, parent: str) -> None: ...
|
||||
def parse_directory_dir(self, value: str, filename: str, parent: str) -> None: ...
|
||||
def parse_default_directory_dir(self, filename: str, parent: str) -> None: ...
|
||||
def parse_merge_file(self, value: str, child: Menu | MenuEntry, filename: str, parent: str) -> None: ...
|
||||
def parse_merge_dir(self, value: str, child: Menu | MenuEntry, filename: str, parent: str) -> None: ...
|
||||
def parse_default_merge_dirs(self, child, filename: str, parent: str) -> None: ...
|
||||
def merge_file(self, filename: str, child: Unused, parent: Menu) -> None: ...
|
||||
def parse_legacy_dir(self, dir_: str, prefix: str, filename: str, parent: str) -> None: ...
|
||||
def merge_legacy_dir(self, dir_: str, prefix: str, filename: str, parent: str) -> Menu: ...
|
||||
def parse_kde_legacy_dirs(self, filename: str, parent: str) -> None: ...
|
||||
def post_parse(self, menu: Menu) -> None: ...
|
||||
def generate_not_only_allocated(self, menu: Menu) -> None: ...
|
||||
def generate_only_allocated(self, menu: Menu) -> None: ...
|
||||
def handle_moves(self, menu: Menu) -> None: ...
|
||||
|
||||
class MenuEntryCache:
|
||||
cacheEntries: dict[str, list[MenuEntry]]
|
||||
cache: dict[str, list[MenuEntry]]
|
||||
def __init__(self) -> None: ...
|
||||
def add_menu_entries(self, dirs: Iterable[str], prefix: str = "", legacy: bool = False) -> None: ...
|
||||
def get_menu_entries(self, dirs: Collection[str], legacy: bool = True) -> list[MenuEntry]: ...
|
||||
|
||||
def parse(filename: str | None = None, debug: bool = False) -> XMLMenuBuilder: ...
|
||||
146
stubs/pyxdg/xdg/MenuEditor.pyi
Normal file
146
stubs/pyxdg/xdg/MenuEditor.pyi
Normal file
@@ -0,0 +1,146 @@
|
||||
from _typeshed import StrPath, Unused
|
||||
from typing import overload
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
from xml.etree.ElementTree import ElementTree
|
||||
|
||||
from .Menu import Menu, MenuEntry, Separator, XMLMenuBuilder
|
||||
|
||||
_MenuItem: TypeAlias = Menu | MenuEntry | Separator
|
||||
|
||||
class MenuEditor:
|
||||
menu: Menu
|
||||
filename: str
|
||||
tree: ElementTree
|
||||
parser: XMLMenuBuilder
|
||||
filenames: list[str]
|
||||
def __init__(self, menu: Menu | None = None, filename: StrPath | None = None, root: bool = False) -> None: ...
|
||||
def parse(self, menu: Menu | None = None, filename: StrPath | None = None, root: bool = False) -> None: ...
|
||||
def save(self) -> None: ...
|
||||
|
||||
# All "before" or "after" items can be one, the other, or neither, but not both.
|
||||
@overload
|
||||
def createMenuEntry(
|
||||
self,
|
||||
parent: Menu | None,
|
||||
name: str,
|
||||
command: str | None = None,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
icon: str | None = None,
|
||||
terminal: bool | None = None,
|
||||
after: _MenuItem | None = None,
|
||||
before: None = None,
|
||||
) -> MenuEntry: ...
|
||||
@overload
|
||||
def createMenuEntry(
|
||||
self,
|
||||
parent: Menu | None,
|
||||
name: str,
|
||||
command: str | None = None,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
icon: str | None = None,
|
||||
terminal: bool | None = None,
|
||||
after: None = None,
|
||||
before: _MenuItem | None = None,
|
||||
) -> MenuEntry: ...
|
||||
@overload
|
||||
def createMenu(
|
||||
self,
|
||||
parent: Menu | None,
|
||||
name: str,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
icon: str | None = None,
|
||||
after: _MenuItem | None = None,
|
||||
before: None = None,
|
||||
) -> Menu: ...
|
||||
@overload
|
||||
def createMenu(
|
||||
self,
|
||||
parent: Menu | None,
|
||||
name: str,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
icon: str | None = None,
|
||||
after: None = None,
|
||||
before: _MenuItem | None = None,
|
||||
) -> Menu: ...
|
||||
@overload
|
||||
def createSeparator(self, parent: Menu, after: _MenuItem | None = None, before: None = None) -> Separator: ...
|
||||
@overload
|
||||
def createSeparator(self, parent: Menu, after: None = None, before: _MenuItem | None = None) -> Separator: ...
|
||||
@overload
|
||||
def moveMenuEntry(
|
||||
self,
|
||||
menuentry: MenuEntry,
|
||||
oldparent: Menu | None,
|
||||
newparent: Menu | None,
|
||||
after: _MenuItem | None = None,
|
||||
before: None = None,
|
||||
) -> MenuEntry: ...
|
||||
@overload
|
||||
def moveMenuEntry(
|
||||
self,
|
||||
menuentry: MenuEntry,
|
||||
oldparent: Menu | None,
|
||||
newparent: Menu | None,
|
||||
after: None = None,
|
||||
before: _MenuItem | None = None,
|
||||
) -> MenuEntry: ...
|
||||
@overload
|
||||
def moveMenu(
|
||||
self, menu: Menu, oldparent: Menu, newparent: Menu, after: _MenuItem | None = None, before: None = None
|
||||
) -> Menu: ...
|
||||
@overload
|
||||
def moveMenu(
|
||||
self, menu: Menu, oldparent: Menu, newparent: Menu, after: None = None, before: _MenuItem | None = None
|
||||
) -> Menu: ...
|
||||
@overload
|
||||
def moveSeparator(
|
||||
self, separator: Separator, parent: Menu, after: _MenuItem | None = None, before: None = None
|
||||
) -> Separator: ...
|
||||
@overload
|
||||
def moveSeparator(
|
||||
self, separator: Separator, parent: Menu, after: None = None, before: _MenuItem | None = None
|
||||
) -> Separator: ...
|
||||
@overload
|
||||
def copyMenuEntry(
|
||||
self, menuentry: MenuEntry, oldparent: Unused, newparent: Menu, after: _MenuItem | None = None, before: None = None
|
||||
) -> MenuEntry: ...
|
||||
@overload
|
||||
def copyMenuEntry(
|
||||
self, menuentry: MenuEntry, oldparent: Unused, newparent: Menu, after: None = None, before: _MenuItem | None = None
|
||||
) -> MenuEntry: ...
|
||||
def editMenuEntry(
|
||||
self,
|
||||
menuentry: MenuEntry,
|
||||
name: str | None = None,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
command: str | None = None,
|
||||
icon: str | None = None,
|
||||
terminal: bool | None = None,
|
||||
nodisplay: bool | None = None,
|
||||
hidden: bool | None = None,
|
||||
) -> MenuEntry: ...
|
||||
def editMenu(
|
||||
self,
|
||||
menu: Menu,
|
||||
name: str | None = None,
|
||||
genericname: str | None = None,
|
||||
comment: str | None = None,
|
||||
icon: str | None = None,
|
||||
nodisplay: bool | None = None,
|
||||
hidden: bool | None = None,
|
||||
) -> Menu: ...
|
||||
def hideMenuEntry(self, menuentry: MenuEntry) -> None: ...
|
||||
def unhideMenuEntry(self, menuentry: MenuEntry) -> None: ...
|
||||
def hideMenu(self, menu: Menu) -> None: ...
|
||||
def unhideMenu(self, menu: Menu) -> None: ...
|
||||
def deleteMenuEntry(self, menuentry: MenuEntry) -> MenuEntry: ...
|
||||
def revertMenuEntry(self, menuentry: MenuEntry) -> MenuEntry: ...
|
||||
def deleteMenu(self, menu: Menu) -> Menu: ...
|
||||
def revertMenu(self, menu: Menu) -> Menu: ...
|
||||
def deleteSeparator(self, separator: Separator) -> Separator: ...
|
||||
def getAction(self, entry: _MenuItem) -> Literal["none", "revert", "delete"]: ...
|
||||
101
stubs/pyxdg/xdg/Mime.pyi
Normal file
101
stubs/pyxdg/xdg/Mime.pyi
Normal file
@@ -0,0 +1,101 @@
|
||||
import re
|
||||
from _typeshed import StrOrBytesPath, SupportsLenAndGetItem, Unused
|
||||
from collections import defaultdict
|
||||
from collections.abc import Collection, Iterable
|
||||
from io import BytesIO
|
||||
from typing_extensions import Literal, Self, TypeAlias
|
||||
|
||||
FREE_NS: str
|
||||
types: dict[str, MIMEtype]
|
||||
exts: Unused | None # This appears to be unused.
|
||||
globs: GlobDB | None
|
||||
literals: Unused | None # This appears to be unused.
|
||||
magic: MagicDB | None
|
||||
PY3: Literal[True]
|
||||
|
||||
_MimeTypeWeightPair: TypeAlias = tuple[MIMEtype, int]
|
||||
|
||||
def lookup(media: str, subtype: str | None = None) -> MIMEtype: ...
|
||||
|
||||
class MIMEtype:
|
||||
def __new__(cls, media: str, subtype: str | None = None) -> Self: ...
|
||||
def get_comment(self) -> str: ...
|
||||
def canonical(self) -> Self: ...
|
||||
def inherits_from(self) -> set[MIMEtype]: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
class UnknownMagicRuleFormat(ValueError): ...
|
||||
class DiscardMagicRules(Exception): ...
|
||||
|
||||
class MagicRule:
|
||||
also: MagicRule | MagicMatchAny | None
|
||||
start: int
|
||||
value: bytes
|
||||
mask: bytes | None
|
||||
word: int
|
||||
range: int
|
||||
def __init__(self, start: int, value: bytes, mask: bytes, word: int, range: int) -> None: ...
|
||||
rule_ending_re: re.Pattern[str]
|
||||
@classmethod
|
||||
def from_file(cls, f: BytesIO) -> tuple[int, MagicRule]: ...
|
||||
def maxlen(self) -> int: ...
|
||||
def match(self, buffer: SupportsLenAndGetItem[bytes]) -> bool: ...
|
||||
def match0(self, buffer: SupportsLenAndGetItem[bytes]) -> bool: ...
|
||||
|
||||
class MagicMatchAny:
|
||||
rules: Collection[MagicRule]
|
||||
def __init__(self, rules: Iterable[MagicRule]) -> None: ...
|
||||
def match(self, buffer: SupportsLenAndGetItem[bytes]) -> bool: ...
|
||||
def maxlen(self) -> int: ...
|
||||
@classmethod
|
||||
def from_file(cls, f: BytesIO) -> MagicMatchAny | MagicRule | None: ...
|
||||
@classmethod
|
||||
def from_rule_tree(cls, tree: list[MagicRule]) -> MagicMatchAny | MagicRule | None: ...
|
||||
|
||||
class MagicDB:
|
||||
bytype: defaultdict[MIMEtype, list[tuple[int, MagicRule]]]
|
||||
def __init__(self) -> None: ...
|
||||
def merge_file(self, fname: StrOrBytesPath) -> None: ...
|
||||
alltypes: list[tuple[int, MIMEtype, MagicRule]]
|
||||
maxlen: int
|
||||
def finalise(self) -> None: ...
|
||||
def match_data(
|
||||
self, data: bytes, max_pri: int = 100, min_pri: int = 0, possible: Iterable[MIMEtype] | None = None
|
||||
) -> MIMEtype: ...
|
||||
def match(
|
||||
self, path: StrOrBytesPath, max_pri: int = 100, min_pri: int = 0, possible: Iterable[MIMEtype] | None = None
|
||||
) -> MIMEtype: ...
|
||||
|
||||
class GlobDB:
|
||||
allglobs: defaultdict[MIMEtype, list[tuple[int, str, str]]]
|
||||
def __init__(self) -> None: ...
|
||||
def merge_file(self, path: StrOrBytesPath) -> None: ...
|
||||
exts: defaultdict[str, list[MIMEtype | int]] # Actually list[MIMEtype, int], but that's not valid.
|
||||
cased_exts: defaultdict[str, list[MIMEtype | int]] # Actually list[MIMEtype, int], but that's not valid.
|
||||
globs: list[tuple[re.Pattern[str], MIMEtype, int]]
|
||||
literals: dict[str, _MimeTypeWeightPair]
|
||||
cased_literals: dict[str, _MimeTypeWeightPair]
|
||||
def finalise(self) -> None: ...
|
||||
def first_match(self, path: StrOrBytesPath) -> _MimeTypeWeightPair | None: ...
|
||||
def all_matches(self, path: StrOrBytesPath) -> list[_MimeTypeWeightPair]: ...
|
||||
|
||||
text: MIMEtype
|
||||
octet_stream: MIMEtype
|
||||
inode_block: MIMEtype
|
||||
inode_char: MIMEtype
|
||||
inode_dir: MIMEtype
|
||||
inode_fifo: MIMEtype
|
||||
inode_socket: MIMEtype
|
||||
inode_symlink: MIMEtype
|
||||
inode_door: MIMEtype
|
||||
app_exe: MIMEtype
|
||||
|
||||
def update_cache() -> None: ...
|
||||
def get_type_by_name(path: StrOrBytesPath) -> _MimeTypeWeightPair | None: ...
|
||||
def get_type_by_contents(path: StrOrBytesPath, max_pri: int = 100, min_pri: int = 0) -> MIMEtype: ...
|
||||
def get_type_by_data(data: bytes, max_pri: int = 100, min_pri: int = 0) -> MIMEtype: ...
|
||||
def get_type(path: StrOrBytesPath, follow: bool = True, name_pri: int = 100) -> MIMEtype: ...
|
||||
def get_type2(path: StrOrBytesPath, follow: bool = True) -> MIMEtype: ...
|
||||
def is_text_file(path: StrOrBytesPath) -> bool: ...
|
||||
def get_extensions(mimetype: MIMEtype) -> set[str]: ...
|
||||
def install_mime_info(application: str, package_file: StrOrBytesPath) -> None: ...
|
||||
28
stubs/pyxdg/xdg/RecentFiles.pyi
Normal file
28
stubs/pyxdg/xdg/RecentFiles.pyi
Normal file
@@ -0,0 +1,28 @@
|
||||
from _typeshed import Incomplete, StrOrBytesPath, StrPath
|
||||
from collections.abc import Iterable
|
||||
|
||||
class RecentFiles:
|
||||
RecentFiles: list[RecentFile]
|
||||
filename: str
|
||||
def __init__(self) -> None: ...
|
||||
def parse(self, filename: StrPath | None = None) -> None: ...
|
||||
def write(self, filename: StrOrBytesPath | None = None) -> None: ...
|
||||
def getFiles(
|
||||
self, mimetypes: Iterable[str] | None = None, groups: Iterable[Incomplete] | None = None, limit: int = 0
|
||||
) -> list[StrPath]: ...
|
||||
def addFile(
|
||||
self, item: StrPath, mimetype: str, groups: Iterable[Incomplete] | None = None, private: bool = False
|
||||
) -> None: ...
|
||||
def deleteFile(self, item: RecentFile | StrPath) -> None: ...
|
||||
def sort(self) -> None: ...
|
||||
|
||||
class RecentFile:
|
||||
URI: str
|
||||
MimeType: str
|
||||
Timestamp: str
|
||||
Private: bool
|
||||
Groups: list[Incomplete]
|
||||
def __init__(self) -> None: ...
|
||||
def __cmp__(self, other: RecentFile) -> int: ...
|
||||
def __lt__(self, other: RecentFile) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
15
stubs/pyxdg/xdg/__init__.pyi
Normal file
15
stubs/pyxdg/xdg/__init__.pyi
Normal file
@@ -0,0 +1,15 @@
|
||||
from . import BaseDirectory, Config, DesktopEntry, Exceptions, IconTheme, IniFile, Locale, Menu, MenuEditor, Mime, RecentFiles
|
||||
|
||||
__all__ = [
|
||||
"BaseDirectory",
|
||||
"Config",
|
||||
"DesktopEntry",
|
||||
"Exceptions",
|
||||
"IconTheme",
|
||||
"IniFile",
|
||||
"Locale",
|
||||
"Menu",
|
||||
"MenuEditor",
|
||||
"Mime",
|
||||
"RecentFiles",
|
||||
]
|
||||
6
stubs/pyxdg/xdg/util.pyi
Normal file
6
stubs/pyxdg/xdg/util.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from shutil import which as which
|
||||
from typing_extensions import Literal
|
||||
|
||||
PY3: Literal[True]
|
||||
|
||||
def u(s: str) -> str: ...
|
||||
Reference in New Issue
Block a user