[ci] auto-format

This commit is contained in:
imayushsaini 2022-12-18 11:24:08 +00:00 committed by github-actions[bot]
parent 90572f7b5d
commit f86623a09a
2 changed files with 60 additions and 55 deletions

View file

@ -67,7 +67,7 @@ ssl._create_default_https_context = ssl._create_unverified_context
def newconnect_to_party(address, port=43210, print_progress=False): def newconnect_to_party(address, port=43210, print_progress=False):
global ip_add global ip_add
global p_port global p_port
dd = _ba.get_connection_to_host_info() dd = _ba.get_connection_to_host_info()
if (dd != {}): if (dd != {}):
_ba.disconnect_from_host() _ba.disconnect_from_host()
@ -1724,7 +1724,7 @@ def fetchAccountInfo(account, loading_widget):
if account in fdata: if account in fdata:
servers = fdata[account] servers = fdata[account]
url = f'https://{BCSSERVER}/player?key={base64.b64encode(account.encode("utf-8")).decode("utf-8")}&base64=true' url = f'https://{BCSSERVER}/player?key={base64.b64encode(account.encode("utf-8")).decode("utf-8")}&base64=true'
data = urllib.request.urlopen(url) data = urllib.request.urlopen(url)
account_data = json.loads(data.read().decode('utf-8'))[0] account_data = json.loads(data.read().decode('utf-8'))[0]
pbid = account_data["pbid"] pbid = account_data["pbid"]
@ -2175,6 +2175,8 @@ class CustomAccountViewerWindow(viewer.AccountViewerWindow):
ba.print_exception('Error displaying account info.') ba.print_exception('Error displaying account info.')
# ba_meta export plugin # ba_meta export plugin
class bySmoothy(ba.Plugin): class bySmoothy(ba.Plugin):
def __init__(self): def __init__(self):
if _ba.env().get("build_number", 0) >= 20577: if _ba.env().get("build_number", 0) >= 20577:

View file

@ -63,6 +63,7 @@ https://ballistica.net/discord
""" """
BCSURL = 'https://bcsserver.bombsquad.ga/bannedservers' BCSURL = 'https://bcsserver.bombsquad.ga/bannedservers'
def is_game_version_lower_than(version): def is_game_version_lower_than(version):
""" """
Returns a boolean value indicating whether the current game Returns a boolean value indicating whether the current game
@ -79,6 +80,7 @@ if is_game_version_lower_than("1.7.7"):
else: else:
ba_internal = ba.internal ba_internal = ba.internal
def updateBannedServersCache(): def updateBannedServersCache():
response = None response = None
config = ba.app.config config = ba.app.config
@ -508,61 +510,62 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu,
def _update_party_lists(self) -> None: def _update_party_lists(self) -> None:
if not self._party_lists_dirty: if not self._party_lists_dirty:
return return
starttime = time.time() starttime = time.time()
config = ba.app.config config = ba.app.config
bannedservers = config.get('Banned Servers',[]) bannedservers = config.get('Banned Servers', [])
assert len(self._parties_sorted) == len(self._parties) assert len(self._parties_sorted) == len(self._parties)
self._parties_sorted.sort( self._parties_sorted.sort(
key=lambda p: ( key=lambda p: (
p[1].ping if p[1].ping is not None else 999999.0, p[1].ping if p[1].ping is not None else 999999.0,
p[1].index, p[1].index,
) )
)
# If signed out or errored, show no parties.
if (
ba.internal.get_v1_account_state() != 'signed_in'
or not self._have_valid_server_list
):
self._parties_displayed = {}
else:
if self._filter_value:
filterval = self._filter_value.lower()
self._parties_displayed = {
k: v
for k, v in self._parties_sorted
if (filterval in v.name.lower() or filterval in v.address) and (v.address not in bannedservers if ENABLE_SERVER_BANNING else True)
}
else:
self._parties_displayed = {
k: v
for k, v in self._parties_sorted
if (v.address not in bannedservers if ENABLE_SERVER_BANNING else True)
}
# Any time our selection disappears from the displayed list, go back to
# auto-selecting the top entry.
if (
self._selection is not None
and self._selection.entry_key not in self._parties_displayed
):
self._have_user_selected_row = False
# Whenever the user hasn't selected something, keep the first visible
# row selected.
if not self._have_user_selected_row and self._parties_displayed:
firstpartykey = next(iter(self._parties_displayed))
self._selection = Selection(firstpartykey, SelectionComponent.NAME)
self._party_lists_dirty = False
if DEBUG_PROCESSING:
print(
f'Sorted {len(self._parties_sorted)} parties in'
f' {time.time()-starttime:.5f}s.'
) )
# If signed out or errored, show no parties.
if (
ba.internal.get_v1_account_state() != 'signed_in'
or not self._have_valid_server_list
):
self._parties_displayed = {}
else:
if self._filter_value:
filterval = self._filter_value.lower()
self._parties_displayed = {
k: v
for k, v in self._parties_sorted
if (filterval in v.name.lower() or filterval in v.address) and (v.address not in bannedservers if ENABLE_SERVER_BANNING else True)
}
else:
self._parties_displayed = {
k: v
for k, v in self._parties_sorted
if (v.address not in bannedservers if ENABLE_SERVER_BANNING else True)
}
# Any time our selection disappears from the displayed list, go back to
# auto-selecting the top entry.
if (
self._selection is not None
and self._selection.entry_key not in self._parties_displayed
):
self._have_user_selected_row = False
# Whenever the user hasn't selected something, keep the first visible
# row selected.
if not self._have_user_selected_row and self._parties_displayed:
firstpartykey = next(iter(self._parties_displayed))
self._selection = Selection(firstpartykey, SelectionComponent.NAME)
self._party_lists_dirty = False
if DEBUG_PROCESSING:
print(
f'Sorted {len(self._parties_sorted)} parties in'
f' {time.time()-starttime:.5f}s.'
)
def replace(): def replace():
manualtab.ManualGatherTab._build_favorites_tab = new_build_favorites_tab manualtab.ManualGatherTab._build_favorites_tab = new_build_favorites_tab
@ -697,5 +700,5 @@ class InitalRun(ba.Plugin):
def __init__(self): def __init__(self):
replace() replace()
config = ba.app.config config = ba.app.config
if config["launchCount"]% 5 ==0: if config["launchCount"] % 5 == 0:
updateBannedServersCache() updateBannedServersCache()