From 21d5cc28c0e66c0d2e8139ef2f21d4579d4527db Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sat, 2 Oct 2021 12:53:20 -0500 Subject: [PATCH] tidying after the removal of efro.entity --- .efrocachemap | 8 +- Makefile | 5 -- assets/.asset_manifest_public.json | 2 - assets/Makefile | 2 - assets/src/ba_data/python/ba/_assetmanager.py | 1 - docs/ba_module.md | 2 +- tools/bacommon/net.py | 8 -- tools/efro/json.py | 76 ------------------- 8 files changed, 5 insertions(+), 99 deletions(-) delete mode 100644 tools/efro/json.py diff --git a/.efrocachemap b/.efrocachemap index c8394dc7..62f07bd9 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3945,10 +3945,10 @@ "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b6/a7/76a39b05d1db2d49dc3335679573", "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/56/a1576a8bee94a47cdd633aa86a3b", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/2b/8d/4b1084de33fe4ef3a2d0313d6330", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/a4/27/cb310b4e2eeb51fb9114f6d402ea", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8a/97/ad31231721be8515b37bb3cf6fc0", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9e/1e/81ad96ec96e0a3c90fb69d24b38e", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a3/47/4f0897f4a30b2f22ce9ee73f24d0", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6a/b2/0d7498cfc3fd49dd4bdf64b22b11", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ec/ed/434ff203ce89602bd395944d33fe", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/2f/c4cc9c7cb4589a50faf7db7f4c05", "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f6/99/b27c665fcf9f8548abf3f162a736", "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/f6/e2/a712749d266aa8e6c6dade74f08d", "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/70/3de0ba133d288111ae3fc386fbf5", diff --git a/Makefile b/Makefile index 009889f5..e0420344 100644 --- a/Makefile +++ b/Makefile @@ -705,11 +705,6 @@ test-message: @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv \ tests/test_efro/test_message.py -# Individual test with extra output enabled. -test-entity: - @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv \ - tests/test_efro/test_entity.py - # Tell make which of these targets don't represent files. .PHONY: test test-full test-assetmanager diff --git a/assets/.asset_manifest_public.json b/assets/.asset_manifest_public.json index 2be2f247..16266870 100644 --- a/assets/.asset_manifest_public.json +++ b/assets/.asset_manifest_public.json @@ -497,7 +497,6 @@ "ba_data/python/efro/__pycache__/__init__.cpython-38.opt-1.pyc", "ba_data/python/efro/__pycache__/call.cpython-38.opt-1.pyc", "ba_data/python/efro/__pycache__/error.cpython-38.opt-1.pyc", - "ba_data/python/efro/__pycache__/json.cpython-38.opt-1.pyc", "ba_data/python/efro/__pycache__/message.cpython-38.opt-1.pyc", "ba_data/python/efro/__pycache__/net.cpython-38.opt-1.pyc", "ba_data/python/efro/__pycache__/terminal.cpython-38.opt-1.pyc", @@ -518,7 +517,6 @@ "ba_data/python/efro/dataclassio/_prep.py", "ba_data/python/efro/dataclassio/extras.py", "ba_data/python/efro/error.py", - "ba_data/python/efro/json.py", "ba_data/python/efro/message.py", "ba_data/python/efro/net.py", "ba_data/python/efro/terminal.py", diff --git a/assets/Makefile b/assets/Makefile index a5e04cbb..0a7f9e4f 100644 --- a/assets/Makefile +++ b/assets/Makefile @@ -651,7 +651,6 @@ SCRIPT_TARGETS_PY_PUBLIC_TOOLS = \ build/ba_data/python/efro/dataclassio/_prep.py \ build/ba_data/python/efro/dataclassio/extras.py \ build/ba_data/python/efro/error.py \ - build/ba_data/python/efro/json.py \ build/ba_data/python/efro/message.py \ build/ba_data/python/efro/net.py \ build/ba_data/python/efro/terminal.py \ @@ -672,7 +671,6 @@ SCRIPT_TARGETS_PYC_PUBLIC_TOOLS = \ build/ba_data/python/efro/dataclassio/__pycache__/_prep.cpython-38.opt-1.pyc \ build/ba_data/python/efro/dataclassio/__pycache__/extras.cpython-38.opt-1.pyc \ build/ba_data/python/efro/__pycache__/error.cpython-38.opt-1.pyc \ - build/ba_data/python/efro/__pycache__/json.cpython-38.opt-1.pyc \ build/ba_data/python/efro/__pycache__/message.cpython-38.opt-1.pyc \ build/ba_data/python/efro/__pycache__/net.cpython-38.opt-1.pyc \ build/ba_data/python/efro/__pycache__/terminal.cpython-38.opt-1.pyc \ diff --git a/assets/src/ba_data/python/ba/_assetmanager.py b/assets/src/ba_data/python/ba/_assetmanager.py index ab647406..33645183 100644 --- a/assets/src/ba_data/python/ba/_assetmanager.py +++ b/assets/src/ba_data/python/ba/_assetmanager.py @@ -38,7 +38,6 @@ class State: files: Annotated[Dict[str, FileValue], IOAttrs('files')] = field(default_factory=dict) - # files = entity.CompoundDictField('files', str, FileValue()) class AssetManager: diff --git a/docs/ba_module.md b/docs/ba_module.md index 95ac7540..f80dbc50 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2021-10-01 for Ballistica version 1.6.5 build 20393

+

last updated on 2021-10-02 for Ballistica version 1.6.5 build 20393

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 let me know. Happy modding!


diff --git a/tools/bacommon/net.py b/tools/bacommon/net.py index cfc7fbc2..6a1f6335 100644 --- a/tools/bacommon/net.py +++ b/tools/bacommon/net.py @@ -20,11 +20,8 @@ if TYPE_CHECKING: class ServerNodeEntry: """Information about a specific server.""" region: Annotated[str, IOAttrs('r')] - # region = entity.Field('r', entity.StringValue()) address: Annotated[str, IOAttrs('a')] - # address = entity.Field('a', entity.StringValue()) port: Annotated[int, IOAttrs('p')] - # port = entity.Field('p', entity.IntValue()) @ioprepped @@ -34,16 +31,11 @@ class ServerNodeQueryResponse: # If present, something went wrong, and this describes it. error: Annotated[Optional[str], IOAttrs('e', store_default=False)] = None - # error = - # entity.Field('e', entity.OptionalStringValue(store_default=False)) # The set of servernodes. servers: Annotated[List[ServerNodeEntry], IOAttrs('s', store_default=False)] = field( default_factory=list) - # servers = entity.CompoundListField('s', - # ServerNodeEntry(), - # store_default=False) @ioprepped diff --git a/tools/efro/json.py b/tools/efro/json.py deleted file mode 100644 index 02d882de..00000000 --- a/tools/efro/json.py +++ /dev/null @@ -1,76 +0,0 @@ -# Released under the MIT License. See LICENSE for details. -# -"""Custom json compressor/decompressor with support for more data times/etc.""" - -from __future__ import annotations - -import datetime -import json -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from typing import Any - -# NOTE: This functionality is duplicated in a newer, cleaner way in -# dataclassio. We should consider deprecating this along with entity at -# some point. - -# Special attr we included for our extended type information -# (extended-json-type) -TYPE_TAG = '_xjtp' - -_pytz_utc: Any - -# We don't *require* pytz since it must be installed through pip -# but it is used by firestore client for its utc tzinfos. -# (in which case it should be installed as a dependency anyway) -try: - import pytz - _pytz_utc = pytz.utc -except ModuleNotFoundError: - _pytz_utc = None # pylint: disable=invalid-name - - -class ExtendedJSONEncoder(json.JSONEncoder): - """Custom json encoder supporting additional types.""" - - def default(self, o: Any) -> Any: - if isinstance(o, datetime.datetime): - - # We only support timezone-aware utc times. - if (o.tzinfo is not datetime.timezone.utc - and (_pytz_utc is None or o.tzinfo is not _pytz_utc)): - raise ValueError( - 'datetime values must have timezone set as timezone.utc') - return { - TYPE_TAG: - 'dt', - 'v': [ - o.year, o.month, o.day, o.hour, o.minute, o.second, - o.microsecond - ], - } - return super().default(o) - - -class ExtendedJSONDecoder(json.JSONDecoder): - """Custom json decoder supporting extended types.""" - - def __init__(self, *args: Any, **kwargs: Any): - json.JSONDecoder.__init__(self, - object_hook=self.object_hook, - *args, - **kwargs) - - def object_hook(self, obj: Any) -> Any: # pylint: disable=E0202 - """Custom hook.""" - if TYPE_TAG not in obj: - return obj - objtype = obj[TYPE_TAG] - if objtype == 'dt': - vals = obj.get('v', []) - if len(vals) != 7: - raise ValueError('malformed datetime value') - return datetime.datetime( # type: ignore - *vals, tzinfo=datetime.timezone.utc) - return obj