minor fix

This commit is contained in:
2026-05-08 15:28:12 +08:00
parent 760b88faee
commit c693d624fc

23
main.py
View File

@@ -379,27 +379,20 @@ def main(driver: WebDriver, logger = logging.getLogger('main')):
progress['number'] = number
progress['index'] = i-1
if (x := item['category_id']) not in categories:
if 'error' in (res := fetch(f'{base}/categories/{x}.json?api_token={profile.token}')):
error = res['error']
code = res['code']
if (category := categories.get(o := item['category_id'])) is None:
if 'error' in (category := fetch(f'{base}/categories/{o}.json?api_token={profile.token}')):
error = category['error']
code = category['code']
logger.warning("Error while fetching 'category' (code: %s, message: %s); skipping", code, error)
continue
categories[x] = res
if (x := item['client_id']) not in clients:
if 'error' in (res := fetch(f'{base}/clients/{x}.json?api_token={profile.token}')):
error = res['error']
code = res['code']
if (client := clients.get(o := item['client_id'])) is None:
if 'error' in (client := fetch(f'{base}/clients/{o}.json?api_token={profile.token}')):
error = client['error']
code = client['code']
logger.warning("Error while fetching 'client' (code: %s, message: %s); skipping", code, error)
continue
clients[x] = res
category = categories.get(item['category_id'])
client = clients.get(item['client_id'])
identity = client['external_id'] if client['company'] else profile.person
date: str = item['issue_date']
kind: str = item['kind']