added extend symbol change for ws
This commit is contained in:
@@ -5,7 +5,7 @@ import os
|
||||
|
||||
load_dotenv()
|
||||
|
||||
def upsert_list_of_dicts_by_id(list_of_dicts, new_dict, id='id', seq_check_field: str | None = None):
|
||||
def upsert_list_of_dicts_by_id(list_of_dicts, new_dict, id='id', seq_check_field: str | None = None) -> list[dict]:
|
||||
for index, item in enumerate(list_of_dicts):
|
||||
if item.get(id) == new_dict.get(id):
|
||||
if seq_check_field is not None:
|
||||
@@ -25,4 +25,19 @@ def send_tg_alert(msg: str):
|
||||
url = f'https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}'
|
||||
response = requests.post(url, json={'text': str(str(msg)[:250])}, timeout=10)
|
||||
|
||||
return response.json()
|
||||
return response.json()
|
||||
|
||||
def rec_set_dict(orig_dict, new_dict, allow_new_fields: bool = False) -> dict:
|
||||
for k, v in new_dict.items():
|
||||
if isinstance(v, dict):
|
||||
rec_set_dict(orig_dict=orig_dict[k], new_dict=v)
|
||||
else:
|
||||
if allow_new_fields:
|
||||
orig_dict[k] = v
|
||||
else:
|
||||
if orig_dict.get(k, None) is not None:
|
||||
orig_dict[k] = v
|
||||
else:
|
||||
logging.warning(msg=f'rec_set_dict: encountered nonexistent key: "{k}"; skipping')
|
||||
|
||||
return orig_dict
|
||||
Reference in New Issue
Block a user