Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120866899
bibtex2bip.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jul 7, 14:09
Size
785 B
Mime Type
text/x-python
Expires
Wed, Jul 9, 14:09 (2 d)
Engine
blob
Format
Raw Data
Handle
27261815
Attached To
R3596 pybliographer
bibtex2bip.py
View Options
"""
Parse a BibTeX file into a BIP (a native pybliographer database) file.
Usage: bibtex2bip.py <BibTeX file> <BIP file>
"""
import
sys
,
os
in_f
,
out_f
=
sys
.
argv
[
1
:
3
]
from
Pyblio.Parsers.Semantic
import
BibTeX
from
Pyblio
import
Store
,
Registry
Registry
.
load_default_settings
()
# This id refers to the bibtex format as known by pybliographer by
# default.
sid
=
"org.pybliographer/bibtex/0.1"
# Get the schema associated with the specified id
schema
=
Registry
.
getSchema
(
sid
)
# Create a new db using this schema. We need to ensure the file does
# not exist yet.
try
:
os
.
unlink
(
out_f
)
except
OSError
:
pass
db
=
Store
.
get
(
'file'
)
.
dbcreate
(
out_f
,
schema
)
# Import the content of the bibtex file into it
fd
=
open
(
in_f
)
reader
=
BibTeX
.
Reader
()
reader
.
parse
(
fd
,
db
)
db
.
save
()
Event Timeline
Log In to Comment