> Now I just need to get the the script to automatically fill in all the
> metadata ;)
I fill in meta-data with the following AppleScript and Python script:
(*
This script
1) For each selected BibDesk publication
2) Passes the DOI to doi2bib.py
3) Uses the BibTeX entry returned to fill in missing fields in the current
publication
*)
global pythonPath
set pythonPath to
"/Users/mankoff/Library/Enthought/Canopy_64bit/User/bin/python" -- where is
Python?
global doi2bibPath
set doi2bibPath to "/Users/mankoff/bin/doi2bib.py" -- where is doi2bib.py?
global iconv
-- set iconv to " /usr/bin/iconv --from-code UTF-8 --to-code US-ASCII -c
inputfile > outputfile
set iconv to " | /usr/bin/iconv -c "
tell application "BibDesk"
set theDoc to document 1
tell theDoc
set theSel to selection
--set thePubs to selection
if (count of theSel) > 0 then
repeat with thePub in theSel
tell thePub
set theDOI to get value of field "DOI"
set theArg to "\"" & theDOI & "\""
set shellOpts to "cd /tmp; "
set doi2bibCmd to " " & pythonPath & " " & doi2bibPath
set shellCmd to shellOpts & doi2bibCmd & " " & theArg & " "
& iconv
display dialog shellCmd
set shellOutput to do shell script shellCmd
end tell
display dialog shellOutput
set newPubs to import from shellOutput
set newPub to (get item 1 of newPubs)
tell newPub
set theAuthors to the value of field "Author"
set theJournal to the value of field "Journal"
set theYear to the value of field "Year"
set theTitle to the value of field "Title"
set theNum to the value of field "Number"
set theVol to the value of field "Volume"
set thePages to the value of field "Pages"
end tell
tell thePub
if the value of field "Author" is "" then set the value of
field "Author" to theAuthors
if the value of field "Year" is "" then set the value of
field "Year" to theYear
if the value of field "Journal" is "" then set the value of
field "Journal" to theJournal
if the value of field "Title" is "" then set the value of
field "Title" to "{" & theTitle & "}"
if the value of field "Number" is "" then set the value of
field "Number" to theNum
if the value of field "Volume" is "" then set the value of
field "Volume" to theVol
if the value of field "Pages" is "" then set the value of
field "Pages" to thePages
end tell
show thePub
delete newPub
end repeat
else
display dialog "Nothing Selected"
end if
end tell
end tell
Python script:
#!/usr/bin/env python
# https://gist.github.com/jrsmith3/5513926
import requests
import sys
def doi2bib(doi):
"""
Return a bibTeX string of metadata for a given DOI.
"""
url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"}
r = requests.get(url, headers = headers, timeout=3)
print r.text
return r.text
if __name__ == "__main__":
doi2bib(*sys.argv[1:])
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users