mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-19 13:25:31 +08:00
Syncing latest changes between public/private.
This commit is contained in:
parent
bfd9b5b762
commit
22227554e6
4
.idea/MypyConfig.xml
generated
4
.idea/MypyConfig.xml
generated
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MypyConfigService">
|
||||
<option name="executableName" value="dmypy start --timeout 3600 -- --config-file .mypy.ini --follow-imports=error; dmypy check `tools/snippets scriptfiles`" />
|
||||
<option name="executableName" value="make dmypy" />
|
||||
<option name="pathSuffix" value="/usr/local/bin" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
||||
3
.idea/dictionaries/ericf.xml
generated
3
.idea/dictionaries/ericf.xml
generated
@ -87,6 +87,7 @@
|
||||
<w>assetcache</w>
|
||||
<w>assetdata</w>
|
||||
<w>assetfiles</w>
|
||||
<w>assetmanager</w>
|
||||
<w>assetpack</w>
|
||||
<w>assetpackage</w>
|
||||
<w>assetpackput</w>
|
||||
@ -414,6 +415,7 @@
|
||||
<w>dline</w>
|
||||
<w>dlls</w>
|
||||
<w>dmodule</w>
|
||||
<w>dmypy</w>
|
||||
<w>dname</w>
|
||||
<w>dnames</w>
|
||||
<w>dnode</w>
|
||||
@ -1863,6 +1865,7 @@
|
||||
<w>workdir</w>
|
||||
<w>workflows</w>
|
||||
<w>wpath</w>
|
||||
<w>wref</w>
|
||||
<w>writeclasses</w>
|
||||
<w>writefuncs</w>
|
||||
<w>wtcolor</w>
|
||||
|
||||
13
Makefile
13
Makefile
@ -310,6 +310,14 @@ mypy: prereqs
|
||||
mypy-full: prereqs
|
||||
@tools/snippets mypy -full
|
||||
|
||||
# Run Mypy checks on all Python code using daemon mode.
|
||||
dmypy: prereqs
|
||||
@tools/snippets dmypy
|
||||
|
||||
# Stop the mypy daemon
|
||||
dmypy-stop: prereqs
|
||||
@tools/snippets dmypy -stop
|
||||
|
||||
# Run PyCharm checks on all Python code.
|
||||
pycharm: prereqs
|
||||
@tools/snippets pycharm
|
||||
@ -339,6 +347,11 @@ test: prereqs
|
||||
# Run tests with any caching disabled.
|
||||
test-full: test
|
||||
|
||||
# Some individual tests for iterating.
|
||||
test-assetmanager:
|
||||
@tools/snippets pytest \
|
||||
-s -v tests/test_ba/test_assetmanager.py::test_assetmanager
|
||||
|
||||
# Tell make which of these targets don't represent files.
|
||||
.PHONY: test test-full
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
"ba_data/python/ba/__pycache__/_appconfig.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_appdelegate.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_apputils.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_assetmanager.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_benchmark.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_campaign.cpython-37.opt-1.pyc",
|
||||
"ba_data/python/ba/__pycache__/_coopgame.cpython-37.opt-1.pyc",
|
||||
@ -58,6 +59,7 @@
|
||||
"ba_data/python/ba/_appconfig.py",
|
||||
"ba_data/python/ba/_appdelegate.py",
|
||||
"ba_data/python/ba/_apputils.py",
|
||||
"ba_data/python/ba/_assetmanager.py",
|
||||
"ba_data/python/ba/_benchmark.py",
|
||||
"ba_data/python/ba/_campaign.py",
|
||||
"ba_data/python/ba/_coopgame.py",
|
||||
|
||||
@ -181,6 +181,7 @@ SCRIPT_TARGETS_PY_1 = \
|
||||
build/ba_data/python/ba/_store.py \
|
||||
build/ba_data/python/ba/_activitytypes.py \
|
||||
build/ba_data/python/ba/__init__.py \
|
||||
build/ba_data/python/ba/_assetmanager.py \
|
||||
build/ba_data/python/ba/_session.py \
|
||||
build/ba_data/python/ba/_hooks.py \
|
||||
build/ba_data/python/ba/_enums.py \
|
||||
@ -417,6 +418,7 @@ SCRIPT_TARGETS_PYC_1 = \
|
||||
build/ba_data/python/ba/__pycache__/_store.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/_activitytypes.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/__init__.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/_assetmanager.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/_session.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/_hooks.cpython-37.opt-1.pyc \
|
||||
build/ba_data/python/ba/__pycache__/_enums.cpython-37.opt-1.pyc \
|
||||
@ -821,6 +823,11 @@ build/ba_data/python/ba/__pycache__/__init__.cpython-37.opt-1.pyc: \
|
||||
@echo Compiling script: $^
|
||||
@rm -rf $@ && $(TOOLS_DIR)/snippets compile_python_files $^ && chmod 444 $@
|
||||
|
||||
build/ba_data/python/ba/__pycache__/_assetmanager.cpython-37.opt-1.pyc: \
|
||||
build/ba_data/python/ba/_assetmanager.py
|
||||
@echo Compiling script: $^
|
||||
@rm -rf $@ && $(TOOLS_DIR)/snippets compile_python_files $^ && chmod 444 $@
|
||||
|
||||
build/ba_data/python/ba/__pycache__/_session.cpython-37.opt-1.pyc: \
|
||||
build/ba_data/python/ba/_session.py
|
||||
@echo Compiling script: $^
|
||||
|
||||
31
assets/src/ba_data/python/ba/_assetmanager.py
Normal file
31
assets/src/ba_data/python/ba/_assetmanager.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2011-2020 Eric Froemling
|
||||
#
|
||||
# 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.
|
||||
# -----------------------------------------------------------------------------
|
||||
"""Functionality related to managing cloud based assets."""
|
||||
|
||||
|
||||
class AssetManager:
|
||||
"""Wrangles all assets."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
print('AssetManager()')
|
||||
|
||||
def __del__(self) -> None:
|
||||
print('~AssetManager()')
|
||||
@ -288,6 +288,9 @@ def make_hash(obj: Any) -> int:
|
||||
|
||||
Note that this uses Python's hash() function internally so collisions/etc.
|
||||
may be more common than with fancy cryptographic hashes.
|
||||
|
||||
Also be aware that Python's hash() output varies across processes, so
|
||||
this should only be used for values that will remain in a single process.
|
||||
"""
|
||||
import copy
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<!--DOCSHASH=a9af83504c95ee68b2281719192df567-->
|
||||
<h4><em>last updated on 2020-02-19 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<!--DOCSHASH=03d4e0e0a8991c9db5174ca7111ff595-->
|
||||
<h4><em>last updated on 2020-03-05 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<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>
|
||||
<hr>
|
||||
|
||||
20
tests/test_ba/__init__.py
Normal file
20
tests/test_ba/__init__.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2011-2020 Eric Froemling
|
||||
#
|
||||
# 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.
|
||||
# -----------------------------------------------------------------------------
|
||||
44
tests/test_ba/test_assetmanager.py
Normal file
44
tests/test_ba/test_assetmanager.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2011-2020 Eric Froemling
|
||||
#
|
||||
# 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.
|
||||
# -----------------------------------------------------------------------------
|
||||
"""Testing asset manager functionality."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
import weakref
|
||||
# noinspection PyProtectedMember
|
||||
from ba._assetmanager import AssetManager
|
||||
|
||||
# import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
def test_assetmanager() -> None:
|
||||
"""Testing."""
|
||||
|
||||
manager = AssetManager()
|
||||
wref = weakref.ref(manager)
|
||||
|
||||
# Make sure it's not keeping itself alive.
|
||||
del manager
|
||||
assert wref() is None
|
||||
@ -524,7 +524,7 @@ def runmypy(filenames: List[str],
|
||||
|
||||
|
||||
def mypy(projroot: Path, full: bool) -> None:
|
||||
"""Run mypy on all of our scripts."""
|
||||
"""Type check all of our scripts using mypy."""
|
||||
import time
|
||||
filenames = get_script_filenames(projroot)
|
||||
print('Running Mypy ' + ('(full)' if full else '(incremental)') + '...',
|
||||
@ -539,6 +539,31 @@ def mypy(projroot: Path, full: bool) -> None:
|
||||
print(f'Mypy passed in {duration:.1f} seconds.', flush=True)
|
||||
|
||||
|
||||
def dmypy(projroot: Path) -> None:
|
||||
"""Type check all of our scripts using mypy in daemon mode."""
|
||||
import time
|
||||
filenames = get_script_filenames(projroot)
|
||||
|
||||
# Special case; explicitly kill the daemon.
|
||||
if '-stop' in sys.argv:
|
||||
subprocess.run(['dmypy', 'stop'], check=False)
|
||||
return
|
||||
|
||||
print('Running Mypy (daemon)...', flush=True)
|
||||
starttime = time.time()
|
||||
try:
|
||||
args = [
|
||||
'dmypy', 'run', '--timeout', '3600', '--', '--config-file',
|
||||
'.mypy.ini', '--follow-imports=error', '--pretty'
|
||||
] + filenames
|
||||
subprocess.run(args, check=True)
|
||||
except Exception:
|
||||
print('Mypy: fail.')
|
||||
sys.exit(255)
|
||||
duration = time.time() - starttime
|
||||
print(f'Mypy daemon passed in {duration:.1f} seconds.', flush=True)
|
||||
|
||||
|
||||
def _parse_idea_results(path: Path) -> int:
|
||||
"""Print errors found in an idea inspection xml file.
|
||||
|
||||
|
||||
@ -262,6 +262,12 @@ def mypy() -> None:
|
||||
code.mypy(PROJROOT, full)
|
||||
|
||||
|
||||
def dmypy() -> None:
|
||||
"""Run mypy checks on our scripts using the mypy daemon."""
|
||||
from efrotools import code
|
||||
code.dmypy(PROJROOT)
|
||||
|
||||
|
||||
def pycharm() -> None:
|
||||
"""Run PyCharm checks on our scripts."""
|
||||
from efrotools import code
|
||||
|
||||
@ -43,9 +43,9 @@ import efrotools
|
||||
# noinspection PyUnresolvedReferences
|
||||
from efrotools.snippets import ( # pylint: disable=unused-import
|
||||
PROJROOT, CleanError, snippets_main, formatcode, formatscripts,
|
||||
formatmakefile, cpplint, pylint, mypy, tool_config_install, sync, sync_all,
|
||||
scriptfiles, pycharm, clioncode, androidstudiocode, makefile_target_list,
|
||||
spelling, spelling_all, compile_python_files, pytest)
|
||||
formatmakefile, cpplint, pylint, mypy, dmypy, tool_config_install, sync,
|
||||
sync_all, scriptfiles, pycharm, clioncode, androidstudiocode,
|
||||
makefile_target_list, spelling, spelling_all, compile_python_files, pytest)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Optional, List, Sequence
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user