This commit is contained in:
Eric Froemling 2020-05-22 16:34:34 -07:00
parent d6ccf2b12d
commit d95da1e439
6 changed files with 82 additions and 67 deletions

View File

@ -24,7 +24,6 @@ This top level module is a collection of most commonly used functionality.
For many modding purposes, the bits exposed here are all you'll need. For many modding purposes, the bits exposed here are all you'll need.
In some specific cases you may need to pull in individual submodules instead. In some specific cases you may need to pull in individual submodules instead.
""" """
# pylint: disable=unused-import # pylint: disable=unused-import
# pylint: disable=redefined-builtin # pylint: disable=redefined-builtin
@ -74,7 +73,7 @@ from ba._apputils import is_browser_likely_available
from ba._campaign import Campaign from ba._campaign import Campaign
from ba._gameutils import (animate, animate_array, show_damage_count, from ba._gameutils import (animate, animate_array, show_damage_count,
sharedobj, timestring, cameraflash) sharedobj, timestring, cameraflash)
from ba._general import WeakCall, Call, existing from ba._general import WeakCall, Call, existing, Existable
from ba._level import Level from ba._level import Level
from ba._lobby import Lobby, Chooser from ba._lobby import Lobby, Chooser
from ba._math import normalized_color, is_point_in_box, vec3validate from ba._math import normalized_color, is_point_in_box, vec3validate

View File

@ -24,28 +24,32 @@ from __future__ import annotations
import types import types
import weakref import weakref
from typing import TYPE_CHECKING, TypeVar from typing import TYPE_CHECKING, TypeVar
from typing_extensions import Protocol
import _ba import _ba
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Type, Optional from typing import Any, Type, Optional
from typing_extensions import Protocol
from efro.call import Call as Call # 'as Call' so we re-export. from efro.call import Call as Call # 'as Call' so we re-export.
class Existable(Protocol):
"""Protocol for objects supporting an exists() method."""
def exists(self) -> bool: class Existable(Protocol):
"""Whether this object exists.""" """A Protocol for objects supporting an exists() method.
...
ExistableType = TypeVar('ExistableType', bound=Existable) Category: Protocols
"""
def exists(self) -> bool:
"""Whether this object exists."""
...
ExistableType = TypeVar('ExistableType', bound=Existable)
T = TypeVar('T') T = TypeVar('T')
def existing(obj: Optional[ExistableType]) -> Optional[ExistableType]: def existing(obj: Optional[ExistableType]) -> Optional[ExistableType]:
"""Convert invalid references to None. """Convert invalid references to None for any ba.Existable type.
Category: Gameplay Functions Category: Gameplay Functions

View File

@ -11,7 +11,8 @@
"pytest", "pytest",
"pytz", "pytz",
"yaml", "yaml",
"requests" "requests",
"typing_extensions"
], ],
"python_paths": [ "python_paths": [
"assets/src/ba_data/python", "assets/src/ba_data/python",

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND --> <!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-05-21 for Ballistica version 1.5.0 build 20026</em></h4> <h4><em>last updated on 2020-05-22 for Ballistica version 1.5.0 build 20026</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module, <p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p> which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr> <hr>
@ -200,6 +200,10 @@
<li><a href="#class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></li> <li><a href="#class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></li>
</ul> </ul>
</ul> </ul>
<h4><a name="class_category_Protocols">Protocols</a></h4>
<ul>
<li><a href="#class_ba_Existable">ba.Existable</a></li>
</ul>
<hr> <hr>
<h2><strong><a name="class_ba_Achievement">ba.Achievement</a></strong></h3> <h2><strong><a name="class_ba_Achievement">ba.Achievement</a></strong></h3>
<p><em>&lt;top level class&gt;</em> <p><em>&lt;top level class&gt;</em>
@ -320,7 +324,7 @@ actually award achievements.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_Activity">ba.Activity</a></strong></h3> <h2><strong><a name="class_ba_Activity">ba.Activity</a></strong></h3>
<p>inherits from: <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p>
<p>Units of execution wrangled by a <a href="#class_ba_Session">ba.Session</a>.</p> <p>Units of execution wrangled by a <a href="#class_ba_Session">ba.Session</a>.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -570,7 +574,7 @@ is a convenient way to access this same functionality.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_ActivityNotFoundError">ba.ActivityNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_ActivityNotFoundError">ba.ActivityNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Activity">ba.Activity</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Activity">ba.Activity</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -733,7 +737,7 @@ likely result in errors.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_ActorNotFoundError">ba.ActorNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_ActorNotFoundError">ba.ActorNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Actor">ba.Actor</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Actor">ba.Actor</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -949,7 +953,7 @@ to resume.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_AppConfig">ba.AppConfig</a></strong></h3> <h2><strong><a name="class_ba_AppConfig">ba.AppConfig</a></strong></h3>
<p>inherits from: dict</p> <p>Inherits from: dict</p>
<p>A special dict that holds the game's persistent configuration values.</p> <p>A special dict that holds the game's persistent configuration values.</p>
<p>Category: <a href="#class_category_App_Classes">App Classes</a></p> <p>Category: <a href="#class_category_App_Classes">App Classes</a></p>
@ -1063,7 +1067,7 @@ when done.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_AssetPackage">ba.AssetPackage</a></strong></h3> <h2><strong><a name="class_ba_AssetPackage">ba.AssetPackage</a></strong></h3>
<p>inherits from: <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a></p> <p>Inherits from: <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a></p>
<p><a href="#class_ba_DependencyComponent">ba.DependencyComponent</a> representing a bundled package of game assets.</p> <p><a href="#class_ba_DependencyComponent">ba.DependencyComponent</a> representing a bundled package of game assets.</p>
<p>Category: <a href="#class_category_Asset_Classes">Asset Classes</a> <p>Category: <a href="#class_category_Asset_Classes">Asset Classes</a>
@ -1465,7 +1469,7 @@ start_long_action(callback_when_done=<a href="#class_ba_ContextCall">ba.ContextC
<hr> <hr>
<h2><strong><a name="class_ba_CoopGameActivity">ba.CoopGameActivity</a></strong></h3> <h2><strong><a name="class_ba_CoopGameActivity">ba.CoopGameActivity</a></strong></h3>
<p>inherits from: <a href="#class_ba_GameActivity">ba.GameActivity</a>, <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_ba_GameActivity">ba.GameActivity</a>, <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p>
<p>Base class for cooperative-mode games.</p> <p>Base class for cooperative-mode games.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a>
@ -1581,7 +1585,7 @@ and it should begin its actual game logic.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_CoopSession">ba.CoopSession</a></strong></h3> <h2><strong><a name="class_ba_CoopSession">ba.CoopSession</a></strong></h3>
<p>inherits from: <a href="#class_ba_Session">ba.Session</a></p> <p>Inherits from: <a href="#class_ba_Session">ba.Session</a></p>
<p>A <a href="#class_ba_Session">ba.Session</a> which runs cooperative-mode games.</p> <p>A <a href="#class_ba_Session">ba.Session</a> which runs cooperative-mode games.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -1669,7 +1673,7 @@ the data object is requested and when it's value is accessed.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_DeathType">ba.DeathType</a></strong></h3> <h2><strong><a name="class_ba_DeathType">ba.DeathType</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>A reason for a death.</p> <p>A reason for a death.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -1686,7 +1690,7 @@ the data object is requested and when it's value is accessed.</p>
</ul> </ul>
<hr> <hr>
<h2><strong><a name="class_ba_Dependency">ba.Dependency</a></strong></h3> <h2><strong><a name="class_ba_Dependency">ba.Dependency</a></strong></h3>
<p>inherits from: <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_typing_Generic">typing.Generic</a></p>
<p>A dependency on a DependencyComponent (with an optional config).</p> <p>A dependency on a DependencyComponent (with an optional config).</p>
<p>Category: <a href="#class_category_Dependency_Classes">Dependency Classes</a></p> <p>Category: <a href="#class_category_Dependency_Classes">Dependency Classes</a></p>
@ -1759,7 +1763,7 @@ on the dep config value. (for instance a map required by a game type)</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_DependencyError">ba.DependencyError</a></strong></h3> <h2><strong><a name="class_ba_DependencyError">ba.DependencyError</a></strong></h3>
<p>inherits from: Exception, BaseException</p> <p>Inherits from: Exception, BaseException</p>
<p>Exception raised when one or more <a href="#class_ba_Dependency">ba.Dependency</a> items are missing.</p> <p>Exception raised when one or more <a href="#class_ba_Dependency">ba.Dependency</a> items are missing.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a></p> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a></p>
@ -1786,7 +1790,7 @@ on the dep config value. (for instance a map required by a game type)</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_DependencySet">ba.DependencySet</a></strong></h3> <h2><strong><a name="class_ba_DependencySet">ba.DependencySet</a></strong></h3>
<p>inherits from: <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_typing_Generic">typing.Generic</a></p>
<p>Set of resolved dependencies and their associated data.</p> <p>Set of resolved dependencies and their associated data.</p>
<p>Category: <a href="#class_category_Dependency_Classes">Dependency Classes</a></p> <p>Category: <a href="#class_category_Dependency_Classes">Dependency Classes</a></p>
@ -1918,7 +1922,7 @@ its time with lingering corpses, sound effects, etc.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_DualTeamSession">ba.DualTeamSession</a></strong></h3> <h2><strong><a name="class_ba_DualTeamSession">ba.DualTeamSession</a></strong></h3>
<p>inherits from: <a href="#class_ba_MultiTeamSession">ba.MultiTeamSession</a>, <a href="#class_ba_Session">ba.Session</a></p> <p>Inherits from: <a href="#class_ba_MultiTeamSession">ba.MultiTeamSession</a>, <a href="#class_ba_Session">ba.Session</a></p>
<p><a href="#class_ba_Session">ba.Session</a> type for teams mode games.</p> <p><a href="#class_ba_Session">ba.Session</a> type for teams mode games.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a>
@ -1935,11 +1939,28 @@ its time with lingering corpses, sound effects, etc.</p>
<p>Set up playlists and launches a <a href="#class_ba_Activity">ba.Activity</a> to accept joiners.</p> <p>Set up playlists and launches a <a href="#class_ba_Activity">ba.Activity</a> to accept joiners.</p>
</dd>
</dl>
<hr>
<h2><strong><a name="class_ba_Existable">ba.Existable</a></strong></h3>
<p>Inherits from: <a href="#class_typing_extensions_Protocol">typing_extensions.Protocol</a></p>
<p>A Protocol for objects supporting an exists() method.</p>
<p>Category: <a href="#class_category_Protocols">Protocols</a>
</p>
<h3>Methods:</h3>
<dl>
<dt><h4><a name="method_ba_Existable__exists">exists()</a></dt></h4><dd>
<p><span>exists(self) -&gt; bool</span></p>
<p>Whether this object exists.</p>
</dd> </dd>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_FreeForAllSession">ba.FreeForAllSession</a></strong></h3> <h2><strong><a name="class_ba_FreeForAllSession">ba.FreeForAllSession</a></strong></h3>
<p>inherits from: <a href="#class_ba_MultiTeamSession">ba.MultiTeamSession</a>, <a href="#class_ba_Session">ba.Session</a></p> <p>Inherits from: <a href="#class_ba_MultiTeamSession">ba.MultiTeamSession</a>, <a href="#class_ba_Session">ba.Session</a></p>
<p><a href="#class_ba_Session">ba.Session</a> type for free-for-all mode games.</p> <p><a href="#class_ba_Session">ba.Session</a> type for free-for-all mode games.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a>
@ -1987,7 +2008,7 @@ its time with lingering corpses, sound effects, etc.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_GameActivity">ba.GameActivity</a></strong></h3> <h2><strong><a name="class_ba_GameActivity">ba.GameActivity</a></strong></h3>
<p>inherits from: <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p>
<p>Common base class for all game ba.Activities.</p> <p>Common base class for all game ba.Activities.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a>
@ -2591,7 +2612,7 @@ prefs, etc.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_InputDeviceNotFoundError">ba.InputDeviceNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_InputDeviceNotFoundError">ba.InputDeviceNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_InputDevice">ba.InputDevice</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_InputDevice">ba.InputDevice</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -2884,7 +2905,7 @@ etc.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_Map">ba.Map</a></strong></h3> <h2><strong><a name="class_ba_Map">ba.Map</a></strong></h3>
<p>inherits from: <a href="#class_ba_Actor">ba.Actor</a></p> <p>Inherits from: <a href="#class_ba_Actor">ba.Actor</a></p>
<p>A game map.</p> <p>A game map.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -3240,7 +3261,7 @@ Use <a href="#function_ba_getmodel">ba.getmodel</a>() to instantiate one.</p>
<hr> <hr>
<h2><strong><a name="class_ba_MultiTeamSession">ba.MultiTeamSession</a></strong></h3> <h2><strong><a name="class_ba_MultiTeamSession">ba.MultiTeamSession</a></strong></h3>
<p>inherits from: <a href="#class_ba_Session">ba.Session</a></p> <p>Inherits from: <a href="#class_ba_Session">ba.Session</a></p>
<p>Common base class for <a href="#class_ba_DualTeamSession">ba.DualTeamSession</a> and <a href="#class_ba_FreeForAllSession">ba.FreeForAllSession</a>.</p> <p>Common base class for <a href="#class_ba_DualTeamSession">ba.DualTeamSession</a> and <a href="#class_ba_FreeForAllSession">ba.FreeForAllSession</a>.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -3404,7 +3425,7 @@ signify that the default soundtrack should be used..</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_MusicPlayMode">ba.MusicPlayMode</a></strong></h3> <h2><strong><a name="class_ba_MusicPlayMode">ba.MusicPlayMode</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Influences behavior when playing music.</p> <p>Influences behavior when playing music.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -3417,7 +3438,7 @@ signify that the default soundtrack should be used..</p>
</ul> </ul>
<hr> <hr>
<h2><strong><a name="class_ba_MusicType">ba.MusicType</a></strong></h3> <h2><strong><a name="class_ba_MusicType">ba.MusicType</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Types of music available to play in-game.</p> <p>Types of music available to play in-game.</p>
<p>Category: <a href="#class_category_Enums">Enums</a></p> <p>Category: <a href="#class_category_Enums">Enums</a></p>
@ -3559,7 +3580,7 @@ acting as an alternative to setting node attributes.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_NodeActor">ba.NodeActor</a></strong></h3> <h2><strong><a name="class_ba_NodeActor">ba.NodeActor</a></strong></h3>
<p>inherits from: <a href="#class_ba_Actor">ba.Actor</a></p> <p>Inherits from: <a href="#class_ba_Actor">ba.Actor</a></p>
<p>A simple <a href="#class_ba_Actor">ba.Actor</a> type that wraps a single <a href="#class_ba_Node">ba.Node</a>.</p> <p>A simple <a href="#class_ba_Actor">ba.Actor</a> type that wraps a single <a href="#class_ba_Node">ba.Node</a>.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -3626,7 +3647,7 @@ even if myactor is set to None.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_NodeNotFoundError">ba.NodeNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_NodeNotFoundError">ba.NodeNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Node">ba.Node</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Node">ba.Node</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -3636,7 +3657,7 @@ even if myactor is set to None.</p>
<p>&lt;all methods inherited from <a href="#class_ba_NotFoundError">ba.NotFoundError</a>&gt;</p> <p>&lt;all methods inherited from <a href="#class_ba_NotFoundError">ba.NotFoundError</a>&gt;</p>
<hr> <hr>
<h2><strong><a name="class_ba_NotFoundError">ba.NotFoundError</a></strong></h3> <h2><strong><a name="class_ba_NotFoundError">ba.NotFoundError</a></strong></h3>
<p>inherits from: Exception, BaseException</p> <p>Inherits from: Exception, BaseException</p>
<p>Exception raised when a referenced object does not exist.</p> <p>Exception raised when a referenced object does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -3662,7 +3683,7 @@ even if myactor is set to None.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_Permission">ba.Permission</a></strong></h3> <h2><strong><a name="class_ba_Permission">ba.Permission</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Permissions that can be requested from the OS.</p> <p>Permissions that can be requested from the OS.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -3720,7 +3741,7 @@ even if myactor is set to None.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_Player">ba.Player</a></strong></h3> <h2><strong><a name="class_ba_Player">ba.Player</a></strong></h3>
<p>inherits from: <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_typing_Generic">typing.Generic</a></p>
<p>A player in a specific <a href="#class_ba_Activity">ba.Activity</a>.</p> <p>A player in a specific <a href="#class_ba_Activity">ba.Activity</a>.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -3879,7 +3900,7 @@ the type-checker properly identifies the returned value as one.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_PlayerNotFoundError">ba.PlayerNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_PlayerNotFoundError">ba.PlayerNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Player">ba.Player</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Player">ba.Player</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -4097,7 +4118,7 @@ change this. Defaults to an empty string.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_ScoreType">ba.ScoreType</a></strong></h3> <h2><strong><a name="class_ba_ScoreType">ba.ScoreType</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Type of scores.</p> <p>Type of scores.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -4348,7 +4369,7 @@ session.set_activity(foo) and then <a href="#function_ba_newnode">ba.newnode</a>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_SessionNotFoundError">ba.SessionNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_SessionNotFoundError">ba.SessionNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Session">ba.Session</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Session">ba.Session</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -4513,7 +4534,7 @@ other players.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_SessionPlayerNotFoundError">ba.SessionPlayerNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_SessionPlayerNotFoundError">ba.SessionPlayerNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_SessionPlayer">ba.SessionPlayer</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_SessionPlayer">ba.SessionPlayer</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -4586,7 +4607,7 @@ of the session.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_SessionTeamNotFoundError">ba.SessionTeamNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_SessionTeamNotFoundError">ba.SessionTeamNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_SessionTeam">ba.SessionTeam</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_SessionTeam">ba.SessionTeam</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -4622,7 +4643,7 @@ of the session.</p>
<hr> <hr>
<h2><strong><a name="class_ba_SpecialChar">ba.SpecialChar</a></strong></h3> <h2><strong><a name="class_ba_SpecialChar">ba.SpecialChar</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Special characters the game can print.</p> <p>Special characters the game can print.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -4829,7 +4850,7 @@ of the session.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_Team">ba.Team</a></strong></h3> <h2><strong><a name="class_ba_Team">ba.Team</a></strong></h3>
<p>inherits from: <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_typing_Generic">typing.Generic</a></p>
<p>A team in a specific <a href="#class_ba_Activity">ba.Activity</a>.</p> <p>A team in a specific <a href="#class_ba_Activity">ba.Activity</a>.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -4859,7 +4880,7 @@ of the session.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_TeamGameActivity">ba.TeamGameActivity</a></strong></h3> <h2><strong><a name="class_ba_TeamGameActivity">ba.TeamGameActivity</a></strong></h3>
<p>inherits from: <a href="#class_ba_GameActivity">ba.GameActivity</a>, <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p> <p>Inherits from: <a href="#class_ba_GameActivity">ba.GameActivity</a>, <a href="#class_ba_Activity">ba.Activity</a>, <a href="#class_ba_DependencyComponent">ba.DependencyComponent</a>, <a href="#class_typing_Generic">typing.Generic</a></p>
<p>Base class for teams and free-for-all mode games.</p> <p>Base class for teams and free-for-all mode games.</p>
<p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p> <p>Category: <a href="#class_category_Gameplay_Classes">Gameplay Classes</a></p>
@ -5074,7 +5095,7 @@ Results for a completed <a href="#class_ba_TeamGameActivity">ba.TeamGameActivity
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_TeamNotFoundError">ba.TeamNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_TeamNotFoundError">ba.TeamNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Team">ba.Team</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Team">ba.Team</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -5110,7 +5131,7 @@ Results for a completed <a href="#class_ba_TeamGameActivity">ba.TeamGameActivity
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_TimeFormat">ba.TimeFormat</a></strong></h3> <h2><strong><a name="class_ba_TimeFormat">ba.TimeFormat</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Specifies the format time values are provided in.</p> <p>Specifies the format time values are provided in.</p>
<p>Category: <a href="#class_category_Enums">Enums</a> <p>Category: <a href="#class_category_Enums">Enums</a>
@ -5188,7 +5209,7 @@ self.t = <a href="#class_ba_Timer">ba.Timer</a>(0.3, say_it, repeat=True)
<hr> <hr>
<h2><strong><a name="class_ba_TimeType">ba.TimeType</a></strong></h3> <h2><strong><a name="class_ba_TimeType">ba.TimeType</a></strong></h3>
<p>inherits from: enum.Enum</p> <p>Inherits from: enum.Enum</p>
<p>Specifies the type of time for various operations to target/use.</p> <p>Specifies the type of time for various operations to target/use.</p>
<p>Category: <a href="#class_category_Enums">Enums</a></p> <p>Category: <a href="#class_category_Enums">Enums</a></p>
@ -5427,7 +5448,7 @@ widgets.</p>
</dl> </dl>
<hr> <hr>
<h2><strong><a name="class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></strong></h3> <h2><strong><a name="class_ba_WidgetNotFoundError">ba.WidgetNotFoundError</a></strong></h3>
<p>inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p> <p>Inherits from: <a href="#class_ba_NotFoundError">ba.NotFoundError</a>, Exception, BaseException</p>
<p>Exception raised when an expected <a href="#class_ba_Widget">ba.Widget</a> does not exist.</p> <p>Exception raised when an expected <a href="#class_ba_Widget">ba.Widget</a> does not exist.</p>
<p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a> <p>Category: <a href="#class_category_Exception_Classes">Exception Classes</a>
@ -5698,7 +5719,7 @@ settings, exiting element counts, or other factors.</p>
<h2><strong><a name="function_ba_existing">ba.existing()</a></strong></h3> <h2><strong><a name="function_ba_existing">ba.existing()</a></strong></h3>
<p><span>existing(obj: Optional[ExistableType]) -&gt; Optional[ExistableType]</span></p> <p><span>existing(obj: Optional[ExistableType]) -&gt; Optional[ExistableType]</span></p>
<p>Convert invalid references to None.</p> <p>Convert invalid references to None for any <a href="#class_ba_Existable">ba.Existable</a> type.</p>
<p>Category: <a href="#function_category_Gameplay_Functions">Gameplay Functions</a></p> <p>Category: <a href="#function_category_Gameplay_Functions">Gameplay Functions</a></p>

View File

@ -374,7 +374,7 @@ def _run_pylint(projroot: Path, pylintrc: Union[Path, str],
result = _apply_pylint_run_to_cache(projroot, run, dirtyfiles, result = _apply_pylint_run_to_cache(projroot, run, dirtyfiles,
allfiles, cache) allfiles, cache)
if result != 0: if result != 0:
raise CleanError(f'Linting failed for {result} file(s).') raise CleanError(f'Pylint failed for {result} file(s).')
# Sanity check: when the linter fails we should always be failing too. # Sanity check: when the linter fails we should always be failing too.
# If not, it means we're probably missing something and incorrectly # If not, it means we're probably missing something and incorrectly
@ -400,6 +400,7 @@ def _apply_pylint_run_to_cache(projroot: Path, run: Any, dirtyfiles: List[str],
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
from astroid import modutils from astroid import modutils
from efrotools import get_config from efrotools import get_config
from efro.error import CleanError
# First off, build a map of dirtyfiles to module names # First off, build a map of dirtyfiles to module names
# (and the corresponding reverse map). # (and the corresponding reverse map).
@ -456,8 +457,8 @@ def _apply_pylint_run_to_cache(projroot: Path, run: Any, dirtyfiles: List[str],
untracked_deps = set(dep for dep in untracked_deps untracked_deps = set(dep for dep in untracked_deps
if dep not in ignored_untracked_deps) if dep not in ignored_untracked_deps)
if untracked_deps: if untracked_deps:
raise Exception( raise CleanError(
f'Found untracked dependencies: {untracked_deps}.' f'Pylint found untracked dependencies: {untracked_deps}.'
' If these are external to your project, add them to' ' If these are external to your project, add them to'
' "pylint_ignored_untracked_deps" in the project config.') ' "pylint_ignored_untracked_deps" in the project config.')
@ -552,7 +553,7 @@ def mypy(projroot: Path, full: bool) -> None:
try: try:
runmypy(projroot, filenames, full) runmypy(projroot, filenames, full)
except Exception: except Exception:
raise CleanError('Mypy: fail.') raise CleanError('Mypy failed.')
duration = time.time() - starttime duration = time.time() - starttime
print(f'{Clr.GRN}Mypy passed in {duration:.1f} seconds.{Clr.RST}', print(f'{Clr.GRN}Mypy passed in {duration:.1f} seconds.{Clr.RST}',
flush=True) flush=True)

View File

@ -248,33 +248,22 @@ def scriptfiles() -> None:
def pylint() -> None: def pylint() -> None:
"""Run pylint checks on our scripts.""" """Run pylint checks on our scripts."""
from efro.error import CleanError
import efrotools.code import efrotools.code
full = ('-full' in sys.argv) full = ('-full' in sys.argv)
fast = ('-fast' in sys.argv) fast = ('-fast' in sys.argv)
try: efrotools.code.pylint(PROJROOT, full, fast)
efrotools.code.pylint(PROJROOT, full, fast)
except Exception:
raise CleanError('Pylint failed.')
def runpylint() -> None: def runpylint() -> None:
"""Run pylint checks on provided filenames.""" """Run pylint checks on provided filenames."""
import os
from efro.terminal import Clr from efro.terminal import Clr
from efro.error import CleanError from efro.error import CleanError
import efrotools.code import efrotools.code
if len(sys.argv) < 3: if len(sys.argv) < 3:
raise CleanError('Expected at least 1 filename arg.') raise CleanError('Expected at least 1 filename arg.')
filenames = sys.argv[2:] filenames = sys.argv[2:]
try: efrotools.code.runpylint(PROJROOT, filenames)
efrotools.code.runpylint(PROJROOT, filenames) print(f'{Clr.GRN}Pylint Passed.{Clr.RST}')
print(f'{Clr.GRN}Pylint Passed.{Clr.RST}')
except Exception:
if os.environ.get('VERBOSE') == '1':
import traceback
traceback.print_exc()
raise CleanError('Pylint Failed.')
def mypy() -> None: def mypy() -> None: