fix root cause: use Zotero-valid character set in key generators
The _zotero_key() functions in add_carrier_to_zotero.py, add_zipcode_to_zotero.py, and bib/sync.py used ascii_uppercase + digits which includes 0, 1, and O — characters outside Zotero's allowed set [23456789ABCDEFGHIJKLMNPQRSTUVWXYZ].
This commit is contained in:
@@ -52,8 +52,8 @@ TAG_YEARS = {2010: 36, 2017: 20}
|
|||||||
|
|
||||||
|
|
||||||
def _zotero_key() -> str:
|
def _zotero_key() -> str:
|
||||||
"""Generate a random 8-char Zotero key (uppercase + digits)."""
|
"""Generate a random 8-char Zotero key using the allowed character set."""
|
||||||
chars = string.ascii_uppercase + string.digits
|
chars = "23456789ABCDEFGHIJKLMNPQRSTUVWXYZ"
|
||||||
return "".join(random.choices(chars, k=8))
|
return "".join(random.choices(chars, k=8))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ TAG_MODULE_PFS = 8
|
|||||||
|
|
||||||
|
|
||||||
def _zotero_key() -> str:
|
def _zotero_key() -> str:
|
||||||
chars = string.ascii_uppercase + string.digits
|
"""Generate a random 8-char Zotero key using the allowed character set."""
|
||||||
|
chars = "23456789ABCDEFGHIJKLMNPQRSTUVWXYZ"
|
||||||
return "".join(random.choices(chars, k=8))
|
return "".join(random.choices(chars, k=8))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import string
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from bib.item import Item
|
from bib.item import Item
|
||||||
@@ -67,8 +66,8 @@ _FIELD_IDS = {
|
|||||||
|
|
||||||
|
|
||||||
def _zotero_key() -> str:
|
def _zotero_key() -> str:
|
||||||
"""Generate an 8-char Zotero-style key."""
|
"""Generate an 8-char Zotero key using the allowed character set."""
|
||||||
chars = string.ascii_uppercase + string.digits
|
chars = "23456789ABCDEFGHIJKLMNPQRSTUVWXYZ"
|
||||||
return "".join(random.choices(chars, k=8)) # noqa: S311
|
return "".join(random.choices(chars, k=8)) # noqa: S311
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user