mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-23 23:49:47 +08:00
latest cloudtool and asset work
This commit is contained in:
parent
e6761ed254
commit
d484f0154a
@ -46,6 +46,30 @@ def utc_now() -> datetime.datetime:
|
||||
return datetime.datetime.now(datetime.timezone.utc)
|
||||
|
||||
|
||||
def data_size_str(bytecount: int) -> str:
|
||||
"""Given a size in bytes, returns a short human readable string.
|
||||
|
||||
This should be 6 or fewer chars for most all sane file sizes.
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements
|
||||
if bytecount <= 999:
|
||||
return f'{bytecount} B'
|
||||
kbytecount = bytecount / 1024
|
||||
if round(kbytecount, 1) < 10.0:
|
||||
return f'{kbytecount:.1f} KB'
|
||||
if round(kbytecount, 0) < 999:
|
||||
return f'{kbytecount:.0f} KB'
|
||||
mbytecount = bytecount / (1024 * 1024)
|
||||
if round(mbytecount, 1) < 10.0:
|
||||
return f'{mbytecount:.1f} MB'
|
||||
if round(mbytecount, 0) < 999:
|
||||
return f'{mbytecount:.0f} MB'
|
||||
gbytecount = bytecount / (1024 * 1024 * 1024)
|
||||
if round(gbytecount, 1) < 10.0:
|
||||
return f'{mbytecount:.1f} GB'
|
||||
return f'{gbytecount:.0f} GB'
|
||||
|
||||
|
||||
class DispatchMethodWrapper(Generic[TARG, TRET]):
|
||||
"""Type-aware standin for the dispatch func returned by dispatchmethod."""
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<!--DOCSHASH=2f4ba682ad3b48baa2f8a93eb9948cb0-->
|
||||
<h4><em>last updated on 2019-12-21 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<!--DOCSHASH=aff21e829575f81236ae45ffa0ed1039-->
|
||||
<h4><em>last updated on 2020-01-04 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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user