Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create(library_id, library_type, api_key):
self = DBInstance()
try:
return DBInstance.dbInstanceCache[(library_id, library_type, api_key)]
except KeyError: # not found
pass
self.zot = None
self.zotLastMod = None
try:
self.zot = zotero.Zotero(library_id, library_type, api_key)
self.zotLastMod = self.zot.last_modified_version() # v1.1.1
DBInstance.dbInstanceCache[(library_id, library_type, api_key)] = self
if library_type == 'group':
log("Loading: https://www.zotero.org/groups/%s/items" % library_id)
else:
log("Loading: %s" % library_id)
except zotero_errors.UserNotAuthorised:
error("UserNotAuthorised: Set correct Zotero API key in settings.py for library ID %s." % library_id)
raise SystemExit(1)
return self
def export_citation(self):
item_id = self.input.split('_')[1]
if self.prefs['csl'] == "odt-scannable-cites":
self._export_scannable_cite()
else:
from pyzotero import zotero
zot = zotero.Zotero(self.settings['user_id'], self.settings['type'], self.settings['api_key'])
ref = zot.item(item_id, content='bib', style=self.prefs['csl'])
uref = z.to_unicode(ref[0])
if self.prefs['format'] == 'Markdown':
citation = self._export_markdown(uref, 'citation')
z.set_clipboard(citation.strip())
elif prefs['format'] == 'Rich Text':
self._export_rtf(uref, 'citation')
return self.prefs['format']
def _get_client(self):
return zotero.Zotero(self.account.provider_id, 'user', self.account.oauth_key)
def init_zotero():
return zotero.Zotero(
library_id=current_app.config['KERKO_ZOTERO_LIBRARY_ID'],
library_type=current_app.config['KERKO_ZOTERO_LIBRARY_TYPE'],
api_key=current_app.config['KERKO_ZOTERO_API_KEY'],
locale=current_app.config['KERKO_ZOTERO_LOCALE']
)
with open(wf.datafile(u"settings.json"), 'r') as f:
data = json.load(f)
f.close()
# Get the user's export preferences
with open(wf.datafile(u"prefs.json"), 'r') as f:
prefs = json.load(f)
f.close()
# Create files, if necessary
if not os.path.exists(wf.cachefile(u"full_bibliography.html")):
with open(wf.cachefile(u"full_bibliography.html"), 'w') as f:
f.write('')
f.close()
# Initiate the call to the Zotero API
zot = zotero.Zotero(data['user_id'], data['type'], data['api_key'])
# If a Collection
if _inp[0] == 'c':
# Get the item key from the system input
coll_key = _inp[1]
# Return a list of HTML formatted citations in preferred style
cites = zot.collection_items(coll_key, content='bib', style=prefs['csl'])
elif _inp[0] == 't':
# Get the item key from the system input
tag_key = _inp[1]
# Return a list of HTML formatted citations in preferred style
try:
cites = zot.tag_items(tag_key, content='bib', style=prefs['csl'])