-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale seems to get ignored #183
Comments
Could you try again using v1.5.24? |
Works as expected with v1.5.24
Thank you for the really quick fix! |
I encountered an error with the added locale when combining the It seems, that at the second Code reproducing this error:from pyzotero import zotero, zotero_errors
def fetch_zotero_entries(locale: str) -> list:
# initialize Text+ library object
tplus_zotero_library = zotero.Zotero(library_id='4533881', library_type='group', locale=locale)
try:
tplus_zotero_library.add_parameters(format='json', include='bibtex,bib,csljson,data', linkwrap='1')
tplus_entries = tplus_zotero_library.everything(tplus_zotero_library.top())
return tplus_entries
except zotero_errors.HTTPError as error:
print(error)
fetch_zotero_entries(locale="de-DE") |
Can you install |
I do not get an error anymore using I also noticed that the JSON using pyzotero is missing the
Also, this is my complete code generating the complete JSON files. Feel free to use it for testing Complete Code# This script collects entries from Zotero using pyzotero and stores them to a local JSON without any further processing
# This is needed, since the response from the API slows down every Hugo build
# Should run every night scheduled by the GitLab CI to keep the JSON updated
import json
import sys
import time
from pyzotero import zotero, zotero_errors
def fetch_zotero_entries(locale: str) -> list:
# init some variables
retry_request_max = 3
# initialize Text+ library object
tplus_zotero_library = zotero.Zotero(library_id='4533881', library_type='group', locale=locale)
for i in range(retry_request_max):
# this loop is needed, because the zotero library is big and API timeouts occur often
try:
# add required formats to request
tplus_zotero_library.add_parameters(format='json', include='bibtex,bib,csljson,data', linkwrap='1')
# request top level items and wrap them in zotero.everything
# a single top() request would only allow up to 100 items per request
tplus_entries = tplus_zotero_library.everything(tplus_zotero_library.top())
return tplus_entries
except zotero_errors.HTTPError:
# wait for 180 seconds, since the Zotero API somtimes needs time to generate the answer
print("Zotero API timeout. Trying again in 180 seconds")
time.sleep(180)
pass
raise TimeoutError(f"Zotero API did not respond in time after {retry_request_max} retries")
def write_zotero_json(data, locale: str):
path = f"zotero-unprocessed.{locale}.json"
with open(path, 'w') as output_file:
json.dump(data, output_file, indent=2)
def refresh_json(locale: str):
zotero_items = fetch_zotero_entries(locale=locale)
if zotero_items is not None:
print(f"Successfully fetched entries for {locale}")
write_zotero_json(zotero_items, locale)
else:
sys.exit(1)
refresh_json("de-DE")
refresh_json("en-US") |
Platform: Arch Linux (also happens in dockered Debian)
Python version: 3.12.5
Pyzotero version: 1.5.20
Problem Description
What were you trying to do?
For our project, we refresh a json containing our zotero library every night for different locales (en-US, de-DE). The resulting files seem to be identical. However, if fetched directly from the API using request, they are different.
What API call did it involve? top items (see code example below)
What error was raised? no direct error
More Details
Our group library is public, using the following code it should be possible to reproduce the error.
Minimal code example:
Hashes of obtained files:
The text was updated successfully, but these errors were encountered: