def get_libzotero(): #import pygnotero zotero_fpath = get_zotero_path() from pygnotero import libzotero #zotero_folder = "/home/sebastiaan/Zotero" zotero = libzotero.libzotero(zotero_fpath) return zotero
def __init__(self): autoconfig.autoconfig.__init__(self, ".gnotero") self.update_check() print print "Welcome to Gnotero %.2f!" % self.version print "Homepage: http://www.cogsci.nl/gnotero" print print "Gnotero is free software, released under the GNU General Public License v3" print "http://www.gnu.org/licenses/gpl.html" print print "Settings are stored in %s" % os.path.join( self.home_folder, ".gnotero") print self.zotero = libzotero.libzotero(self.zotero_folder) if self.notes == "gnote" and self.os == "*nix": self.gnote = libgnote.libgnote(self.home_folder) self.timer_id = None if self.zotero.error: print "gnotero_base.__init__(): an error occured in libzotero" mb = gtk.MessageDialog(buttons=gtk.BUTTONS_OK) mb.set_title("Something went wrong!") mb.set_markup( "<b>Failed to connect to Zotero</b>\n\nAre you running an outdated version of Zotero?" ) mb.run() mb.destroy() quit()
def __init__(self): autoconfig.autoconfig.__init__(self, ".gnotero") self.update_check() print print "Welcome to Gnotero %.2f!" % self.version print "Homepage: http://www.cogsci.nl/gnotero" print print "Gnotero is free software, released under the GNU General Public License v3" print "http://www.gnu.org/licenses/gpl.html" print print "Settings are stored in %s" % os.path.join(self.home_folder, ".gnotero") print self.zotero = libzotero.libzotero(self.zotero_folder) if self.notes == "gnote" and self.os == "*nix": self.gnote = libgnote.libgnote(self.home_folder) self.timer_id = None if self.zotero.error: print "gnotero_base.__init__(): an error occured in libzotero" mb = gtk.MessageDialog(buttons=gtk.BUTTONS_OK) mb.set_title("Something went wrong!") mb.set_markup("<b>Failed to connect to Zotero</b>\n\nAre you running an outdated version of Zotero?") mb.run() mb.destroy() quit()
def locate_zotero(self, event = None): """ Presents a simple preference dialog. Currently, this is simply a locate dialog for the Zotero folfer. """ fd = gtk.FileChooserDialog("Locate Zotero Folder", None, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) if fd.run() == gtk.RESPONSE_OK: self.zotero_folder = fd.get_filename() print "gnoter_base.locate_zotero(): selected %s" % self.zotero_folder if libzotero.valid_location(self.zotero_folder): print "gnoter_base.locate_zotero(): path ok" self.zotero = libzotero.libzotero(self.zotero_folder) else: print "gnoter_base.locate_zotero(): path not ok" fd.destroy() mb = gtk.MessageDialog(buttons=gtk.BUTTONS_OK) mb.set_title("Oops!") mb.set_markup("<b>I could not find zotero.sqlite in this folder</b>\n\nYou can find the Zotero folder in the Advanced section of your Zotero preferences.\n\nPlease try again.") mb.run() mb.destroy() self.locate_zotero() return else: self.messagebox("Cancelled", "You have pressed cancel, exiting Gnotero...") quit() fd.destroy()
def locate_zotero(self, event=None): """ Presents a simple preference dialog. Currently, this is simply a locate dialog for the Zotero folfer. """ fd = gtk.FileChooserDialog("Locate Zotero Folder", None, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) if fd.run() == gtk.RESPONSE_OK: self.zotero_folder = fd.get_filename() print "gnoter_base.locate_zotero(): selected %s" % self.zotero_folder if libzotero.valid_location(self.zotero_folder): print "gnoter_base.locate_zotero(): path ok" self.zotero = libzotero.libzotero(self.zotero_folder) else: print "gnoter_base.locate_zotero(): path not ok" fd.destroy() mb = gtk.MessageDialog(buttons=gtk.BUTTONS_OK) mb.set_title("Oops!") mb.set_markup( "<b>I could not find zotero.sqlite in this folder</b>\n\nYou can find the Zotero folder in the Advanced section of your Zotero preferences.\n\nPlease try again." ) mb.run() mb.destroy() self.locate_zotero() return else: self.messagebox("Cancelled", "You have pressed cancel, exiting Gnotero...") quit() fd.destroy()
# Path to your Zotero folder # You'll need to change this zotero_folder = "/home/ajlyon/.mozilla/firefox/jlm2qjtg.Demo/zotero" # Zotero user ID (numeric) # You'll need to change this too zotero_userid = "5770" # Zotero API key (alphanumeric) # Get it here: http://www.zotero.org/settings/keys/new zotero_key = ".........." # Search term term = 'Highlights of statistical signal and array processing' # Connect to local Zotero database db = libzotero.libzotero(zotero_folder) # Connect to Zotero server server = zotero.Zotero(zotero_userid, zotero_key) results = db.search(term) print "%d results for %s" % (len(results), term) # We'll view the full set here -- at this point we could filter them by any field that Gnotero exposes (not all of them -- yet!) for i in results: print "Have local: %s (%s)" % (i.title, i.key) # get the first result to make a sample edit # We request it from the server, using the key that Gnotero obligingly provides remote = server.item(results[0].key)[0] # Show the object that we pulled from the server print remote # We can modify any of the fields on the item