From 73667386224fe00d12d6ce2866124b1e612f5f96 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 22 Mar 2020 16:29:29 -0700 Subject: [PATCH] work on ba_meta --- assets/src/ba_data/python/ba/_meta.py | 13 ++++++++----- docs/ba_module.md | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/assets/src/ba_data/python/ba/_meta.py b/assets/src/ba_data/python/ba/_meta.py index 6a027665..8ba8088e 100644 --- a/assets/src/ba_data/python/ba/_meta.py +++ b/assets/src/ba_data/python/ba/_meta.py @@ -175,7 +175,7 @@ class DirectoryScan: flines = infile.readlines() meta_lines = { lnum: l[1:].split() - for lnum, l in enumerate(flines) if 'ba_meta' in l + for lnum, l in enumerate(flines) if '# ba_meta ' in l } toplevel = len(subpath.parts) <= 1 required_api = self.get_api_requirement(subpath, meta_lines, toplevel) @@ -218,6 +218,7 @@ class DirectoryScan: # meta_lines is just anything containing 'ba_meta'; make sure # the ba_meta is in the right place. if mline[0] != 'ba_meta': + print(f'GOT "{mline[0]}"') self.results['warnings'] += ( 'Warning: ' + str(subpath) + ': malformed ba_meta statement on line ' + @@ -309,13 +310,14 @@ class DirectoryScan: return None -def getscanresults() -> Dict[str, Any]: +def get_scan_results() -> Dict[str, Any]: """Return meta scan results; blocking if the scan is not yet complete.""" import time app = _ba.app if app.metascan is None: - print('WARNING: ba.meta.getscanresults() called before scan completed.' - ' This can cause hitches.') + print( + 'WARNING: ba.meta.get_scan_results() called before scan completed.' + ' This can cause hitches.') # Now wait a bit for the scan to complete. # Eventually error though if it doesn't. @@ -324,6 +326,7 @@ def getscanresults() -> Dict[str, Any]: time.sleep(0.05) if time.time() - starttime > 10.0: raise Exception('timeout waiting for meta scan to complete.') + print('RETURNING SCAN RESULTS') return app.metascan @@ -331,7 +334,7 @@ def get_game_types() -> List[Type[ba.GameActivity]]: """Return available game types.""" from ba import _general from ba import _gameactivity - gameclassnames = getscanresults().get('games', []) + gameclassnames = get_scan_results().get('games', []) gameclasses = [] for gameclassname in gameclassnames: try: diff --git a/docs/ba_module.md b/docs/ba_module.md index 6c958fcd..3d3be53e 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,6 +1,6 @@ - -

last updated on 2020-03-20 for Ballistica version 1.5.0 build 20001

+ +

last updated on 2020-03-22 for Ballistica version 1.5.0 build 20001

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!