Compare commits

...
11 changed files with 301 additions and 245 deletions
+33 -16
View File
@@ -1,16 +1,16 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Python Package
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
on:
push:
tags: ["*"]
jobs:
deploy:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Replace string
@@ -20,21 +20,38 @@ jobs:
string: ${{ github.ref_name }}
pattern: "v?([0-9][.][0-9][.][0-9]).*"
replace-with: "$1"
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python-version: 3.11
- uses: abatilo/actions-poetry@v2
- name: Build
run: |
cd stubs/setup
mkdir mobase-stubs
cp -r ../${{ steps.version.outputs.replaced }}/mobase-stubs/* mobase-stubs/
sed -i 's/__version__ = ".*"/__version__ = "${{ github.ref_name }}"/' mobase-stubs/__init__.pyi
python setup.py sdist bdist_wheel
twine upload dist/*
TAG=${{ github.ref_name }}
poetry version ${TAG#v}
poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: stubs/setup/dist/
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
+66 -19
View File
@@ -255,7 +255,7 @@ mobase:
type: str
desc: Full path to the file.
origins:
type: List[str]
type: list[str]
desc: |
List of origins containing providing this file. The first origin in the list
is the highest priority one (actually providing the file).
@@ -319,7 +319,7 @@ mobase:
__doc__: |
The parent tree containing this entry, or a `None` if this entry is the root
or the parent tree is unreachable.
type: Optional[IFileTree]
type: IFileTree | None
path:
__doc__: |
@@ -665,7 +665,7 @@ mobase:
__doc__: |
The entry at the given location, or `None` if the entry was not found or
was not of the correct type.
type: Optional[Union[IFileTree, FileTreeEntry]]
type: IFileTree | FileTreeEntry | None
insert:
__doc__: |
@@ -1228,7 +1228,7 @@ mobase:
type: MoVariant
desc: The data that was included in the request.
result_data:
type: Dict[str, MoVariant]
type: dict[str, MoVariant]
desc: The data included in the response.
filesAvailable:
@@ -1244,7 +1244,7 @@ mobase:
type: MoVariant
desc: The data that was included in the request.
result_data:
type: List[ModRepositoryFileInfo]
type: list[ModRepositoryFileInfo]
desc: List of file information objects.
fileInfoAvailable:
@@ -1271,7 +1271,7 @@ mobase:
type: MoVariant
desc: The data that was included in the request.
result_data:
type: Dict[str, MoVariant]
type: dict[str, MoVariant]
desc: The data included in the response.
downloadURLsAvailable:
@@ -1293,7 +1293,7 @@ mobase:
type: MoVariant
desc: The data that was included in the request.
result_data:
type: Dict[str, MoVariant]
type: dict[str, MoVariant]
desc: The data included in the response.
endorsementsAvailable:
@@ -1531,17 +1531,36 @@ mobase:
modsPath:
returns: The (absolute) path to the mods directory.
onAboutToRun:
onAboutToRun.1:
__doc__: |
Install a new handler to be called when an application is about to run.
Multiple handlers can be installed. If any of the handler returns `False`, the application will
not run.
Multiple handlers can be installed. If any of the handler returns `False`, the
application will not run.
args:
callback: |
The function to call when an application is about to run. The parameter is the absolute path
to the application to run. The function can return False to prevent the application from running.
returns: True if the handler was installed properly (there are currently no reasons for this to fail).
The function to call when an application is about to run. The function
receives the absolute path to the application to run, the working directory
for the run and a string containing the arguments passed to the executable.
The function can return False to prevent the application from running.
returns: |
True if the handler was installed properly (there are currently no
reasons for this to fail).
onAboutToRun.2:
__doc__: |
Install a new handler to be called when an application is about to run.
Multiple handlers can be installed. If any of the handler returns `False`, the
application will not run.
args:
callback: |
The function to call when an application is about to run. The parameter
is the absolute path to the application to run. The function can return False
to prevent the application from running.
returns: |
True if the handler was installed properly (there are currently no reasons for
this to fail).
onFinishedRun:
__doc__: Install a new handler to be called when an application has finished running.
@@ -1549,7 +1568,19 @@ mobase:
callback: |
The function to call when an application has finished running. The first parameter is the absolute
path to the application, and the second parameter is the exit code of the application.
returns: True if the handler was installed properly (there are currently no reasons for this to fail).
returns: |
True if the handler was installed properly (there are currently no reasons for
this to fail).
onNextRefresh:
__doc__: Install a new handler to be called on the next refresh or immediately.
args:
callback: Function to call on the next refresh (or immediately).
immediate_if_possible: |
If True, immediately run the callback if no refresh is currently running.
returns: |
True if the handler was installed properly (there are currently no reasons for
this to fail).
onPluginDisabled.1:
__doc__: Install a new handler to be called when a plugin is disabled.
@@ -1951,9 +1982,11 @@ mobase:
See `IPlugin.init()` for more.
CCPlugins:
abstract: false
returns: The current list of active Creation Club plugins.
DLCPlugins:
abstract: false
returns: The list of esp/esm files that are part of known DLCs.
binaryName:
@@ -1965,10 +1998,15 @@ mobase:
documentsDirectory:
returns: The directory of the documents folder where configuration files and such for this game reside.
enabledPlugins:
abstract: false
returns: A list of plugins enabled by the game but not in a strict load order.
executableForcedLoads:
returns: A list of automatically discovered libraries that can be force loaded with executables.
executables:
abstract: false
returns: A list of automatically discovered executables of the game itself and tools surrounding it.
feature:
@@ -1992,7 +2030,7 @@ mobase:
abstract: false
returns:
__doc__: A mapping from feature type to actual game features.
type: Dict[Type[GameFeatureType], GameFeatureType]
type: dict[Type[GameFeatureType], GameFeatureType]
gameDirectory:
returns: The directory containing the game installation.
@@ -2004,12 +2042,14 @@ mobase:
returns: The name of the game (as displayed to the user).
gameNexusName:
abstract: false
returns: The name of the game identifier for Nexus.
gameShortName:
returns: The short name of the game.
gameVariants:
abstract: false
__doc__: |
Retrieve the list of variants for this game.
@@ -2030,6 +2070,7 @@ mobase:
returns: An URL for the support page of this game.
iniFiles:
abstract: false
returns: |
The list of INI files this game uses. The first file in the list should be the
'main' INI file.
@@ -2057,6 +2098,7 @@ mobase:
returns: The list of game saves in the given folder.
loadOrderMechanism:
abstract: false
returns: The load order mechanism used by this game.
looksValid:
@@ -2073,6 +2115,7 @@ mobase:
returns: The Nexus game ID for this game.
nexusModOrganizerID:
abstract: false
__doc__: |
Retrieve the Nexus mod ID of Mod Organizer for this game.
@@ -2081,9 +2124,11 @@ mobase:
returns: The Nexus mod ID of Mod Organizer for this game.
primaryPlugins:
abstract: false
returns: The list of plugins that are part of the game and not considered optional.
primarySources:
abstract: false
__doc__: |
Retrieve primary alternative 'short' names for this game.
@@ -2095,11 +2140,11 @@ mobase:
returns: The directory where save games are stored.
secondaryDataDirectories:
abstract: false
__doc__: |
Retrieve the list of secondary data directories. Each directories should be
assigned a unique name that differs from "data" which is the name of the main
data directory returned by dataDirectory().
returns: A mapping from unique name to secondary data directories.
setGamePath:
@@ -2122,9 +2167,11 @@ mobase:
variant: The game variant selected by the user.
sortMechanism:
abstract: false
returns: The sort mechanism for this game.
steamAPPId:
abstract: false
__doc__: |
Retrieve the Steam app ID for this game.
@@ -2798,7 +2845,7 @@ mobase:
filetree: The tree to try to fix. Can be modified during the process.
returns:
__doc__: The fixed tree, or a null pointer if the tree could not be fixed.
type: Optional["IFileTree"]
type: IFileTree | None
ModDataContent:
__doc__: |
@@ -3008,7 +3055,7 @@ mobase:
parent: The parent widget.
returns:
__doc__: A SaveGameInfoWidget to display information about save game.
type: Optional[ISaveGameInfoWidget]
type: ISaveGameInfoWidget | None
ScriptExtender:
__doc__:
@@ -3185,7 +3232,7 @@ mobase.widgets:
Display this dialog and wait for user-interaction to return. This is a blocking
function.
returns:
returns: |
The button clicked by the user. Without custom buttons, this return Ok,
otherwise it returns the button set in the TaskDialogButton.
+6 -3
View File
@@ -108,9 +108,12 @@ def parse_python_signature(s: str, name: str) -> tuple[PyType, list[Argument]]:
raise ValueError(f"invalid argument: {pa}, {s}")
matches = m.groupdict()
arguments.append(
Argument(matches["name"], PyType(matches["type"]), matches["value"])
)
type_ = matches["type"]
if matches["value"] == "None":
if "None" not in type_ and "MoVariant" not in type_:
type_ = type_ + " | None"
arguments.append(Argument(matches["name"], PyType(type_), matches["value"]))
return PyType(return_type), arguments
+2
View File
@@ -74,6 +74,8 @@ class Writer:
sig_return_type = ""
if not fn.ret.type.is_none():
sig_return_type = " -> " + self._fix_typing(fn.ret.type.typing())
else:
sig_return_type = " -> None"
if isinstance(fn, Method):
if fn.is_static():
File diff suppressed because it is too large Load Diff
@@ -15,7 +15,7 @@ class TaskDialog:
def __init__(
self: TaskDialog,
parent: PyQt6.QtWidgets.QWidget = None,
parent: PyQt6.QtWidgets.QWidget | None = None,
title: str = "",
main: str = "",
content: str = "",
@@ -23,7 +23,7 @@ class TaskDialog:
icon: PyQt6.QtWidgets.QMessageBox.Icon = PyQt6.QtWidgets.QMessageBox.Icon.NoIcon,
buttons: List[TaskDialogButton] = [],
remember: Union[str, Tuple[str, str]] = "",
):
) -> None:
"""
Construct a new TaskDialog.
@@ -46,7 +46,7 @@ class TaskDialog:
button: Button to add to the dialog.
"""
...
def addContent(self: TaskDialog, widget: PyQt6.QtWidgets.QWidget):
def addContent(self: TaskDialog, widget: PyQt6.QtWidgets.QWidget) -> None:
"""
Add a custom widget content to this TaskDialog. Widget content are put between
content and buttons (above buttons).
@@ -61,7 +61,8 @@ class TaskDialog:
function.
Returns:
The button clicked by the user. Without custom buttons, this return Ok, otherwise it returns the button set in the TaskDialogButton.
The button clicked by the user. Without custom buttons, this return Ok,
otherwise it returns the button set in the TaskDialogButton.
"""
...
def setContent(self: TaskDialog, content: str) -> TaskDialog:
@@ -113,7 +114,7 @@ class TaskDialog:
title: Title of the dialog.
"""
...
def setWidth(self: TaskDialog, width: int):
def setWidth(self: TaskDialog, width: int) -> None:
"""
Set the width of the dialog.
@@ -145,7 +146,7 @@ class TaskDialogButton:
text: str,
description: str,
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
):
) -> None:
"""
Create a TaskDialogButton.
@@ -160,7 +161,7 @@ class TaskDialogButton:
self: TaskDialogButton,
text: str,
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
):
) -> None:
"""
Create a TaskDialogButton without description.
-21
View File
@@ -1,21 +0,0 @@
Copyright 2020 © Holt59
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
View File
+7
View File
@@ -0,0 +1,7 @@
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
package = []
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "81b2fa642d7f2d1219cf80112ace12d689d053d81be7f7addb98144d56fc0fb2"
+18
View File
@@ -0,0 +1,18 @@
[tool.poetry]
name = "mobase-stubs"
version = "v2.5.0.dev12"
description = "PEP561 stub files for the mobase Python API."
authors = ["Holt59 <capelle.mikael@gmail.com>"]
license = "MIT"
readme = "README.md"
packages = [{ include = "mobase-stubs" }]
homepage = "https://www.modorganizer.org/python-plugins-doc/"
documentation = "https://www.modorganizer.org/python-plugins-doc/"
repository = "https://github.com/ModOrganizer2/mo2-pystubs-generation"
[tool.poetry.dependencies]
python = "^3.11"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
-69
View File
@@ -1,69 +0,0 @@
"""Python setup script.
:author: Stefan Lehmann <stlm@posteo.de>
:license: MIT, see license file or https://opensource.org/licenses/MIT
:created on 2018-10-06 10:55:36
:last modified by: Stefan Lehmann
:last modified time: 2019-07-23 10:27:04
"""
import io
import os
import re
from collections import defaultdict
from pathlib import Path
from setuptools import setup
def read(*names, **kwargs):
try:
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8"),
) as fp:
return fp.read()
except IOError:
return ""
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
def find_package_data(path: str):
package_data: dict[str, list[str]] = defaultdict(lambda: [])
for stubfile in Path(path).glob("**/*.pyi"):
package_data[stubfile.parent.as_posix().replace("/", ".")].append(stubfile.name)
return dict(package_data)
long_description = read("README.md")
package_data = find_package_data("mobase-stubs")
setup(
name="mobase-stubs",
url="https://github.com/ModOrganizer2/mo2-pystubs-generation",
author="Holt59",
author_email="capelle.mikael@gmail.com",
description="PEP561 stub files for the mobase python API",
long_description=long_description,
long_description_content_type="text/markdown",
version=find_version("mobase-stubs", "__init__.pyi"),
packages=list(package_data.keys()),
package_data=package_data,
install_requires=[],
python_requires="==3.11.*",
classifiers=[
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development",
],
)