work on ba_meta

This commit is contained in:
Eric Froemling 2020-03-22 16:29:29 -07:00
parent 7fe0b3a1dc
commit 7366738622
2 changed files with 10 additions and 7 deletions

View File

@ -175,7 +175,7 @@ class DirectoryScan:
flines = infile.readlines() flines = infile.readlines()
meta_lines = { meta_lines = {
lnum: l[1:].split() 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 toplevel = len(subpath.parts) <= 1
required_api = self.get_api_requirement(subpath, meta_lines, toplevel) 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 # meta_lines is just anything containing 'ba_meta'; make sure
# the ba_meta is in the right place. # the ba_meta is in the right place.
if mline[0] != 'ba_meta': if mline[0] != 'ba_meta':
print(f'GOT "{mline[0]}"')
self.results['warnings'] += ( self.results['warnings'] += (
'Warning: ' + str(subpath) + 'Warning: ' + str(subpath) +
': malformed ba_meta statement on line ' + ': malformed ba_meta statement on line ' +
@ -309,13 +310,14 @@ class DirectoryScan:
return None 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.""" """Return meta scan results; blocking if the scan is not yet complete."""
import time import time
app = _ba.app app = _ba.app
if app.metascan is None: if app.metascan is None:
print('WARNING: ba.meta.getscanresults() called before scan completed.' print(
' This can cause hitches.') 'WARNING: ba.meta.get_scan_results() called before scan completed.'
' This can cause hitches.')
# Now wait a bit for the scan to complete. # Now wait a bit for the scan to complete.
# Eventually error though if it doesn't. # Eventually error though if it doesn't.
@ -324,6 +326,7 @@ def getscanresults() -> Dict[str, Any]:
time.sleep(0.05) time.sleep(0.05)
if time.time() - starttime > 10.0: if time.time() - starttime > 10.0:
raise Exception('timeout waiting for meta scan to complete.') raise Exception('timeout waiting for meta scan to complete.')
print('RETURNING SCAN RESULTS')
return app.metascan return app.metascan
@ -331,7 +334,7 @@ def get_game_types() -> List[Type[ba.GameActivity]]:
"""Return available game types.""" """Return available game types."""
from ba import _general from ba import _general
from ba import _gameactivity from ba import _gameactivity
gameclassnames = getscanresults().get('games', []) gameclassnames = get_scan_results().get('games', [])
gameclasses = [] gameclasses = []
for gameclassname in gameclassnames: for gameclassname in gameclassnames:
try: try:

View File

@ -1,6 +1,6 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND --> <!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<!--DOCSHASH=c798f5512eafca1a6a4e19f5fe5ae860--> <!--DOCSHASH=980152c92470347b729403636dcd2a7f-->
<h4><em>last updated on 2020-03-20 for Ballistica version 1.5.0 build 20001</em></h4> <h4><em>last updated on 2020-03-22 for Ballistica version 1.5.0 build 20001</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>