Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97876712
ut_xmlmarc.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
Tue, Jan 7, 02:05
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Jan 9, 02:05 (2 d)
Engine
blob
Format
Raw Data
Handle
23425844
Attached To
R3596 pybliographer
ut_xmlmarc.py
View Options
# -*- coding: latin-1 -*-
import
os
,
pybut
,
sys
from
Pyblio.Parsers.Syntax
import
XMLMARC
from
Pyblio
import
Store
,
Schema
SI
=
XMLMARC
.
SimpleReader
mapping
=
{
001
:
'marc-id'
,
(
245
,
''
,
''
,
'a'
)
:
'title'
,
(
700
,
''
,
''
,
'a'
)
:
'author'
,
(
773
,
''
,
''
,
'p'
)
:
'journal'
,
(
856
,
'4'
,
''
,
'u'
)
:
'url'
,
}
class
TestImport
(
pybut
.
TestCase
):
""" Perform tests on the Pyblio.Parsers.Syntax.BibTeX module """
def
_check
(
self
,
base
):
f
=
pybut
.
dbname
()
s
=
Schema
.
Schema
(
pybut
.
src
(
'ut_xmlmarc/schema.xml'
))
db
=
Store
.
get
(
'file'
)
.
dbcreate
(
f
,
s
)
self
.
parser
=
XMLMARC
.
SimpleReader
(
mapping
)
rs
=
self
.
parser
.
parse
(
open
(
pybut
.
src
(
'ut_xmlmarc/
%s
.xml'
%
base
)),
db
)
db
.
rs
.
update
(
rs
)
db
.
save
()
pybut
.
fileeq
(
f
,
pybut
.
src
(
'ut_xmlmarc/r-
%s
.xml'
%
base
))
Store
.
get
(
'file'
)
.
dbdestroy
(
f
,
nobackup
=
True
)
return
def
testBase
(
self
):
self
.
_check
(
'simple'
)
def
testControl
(
self
):
""" handling of control fields """
self
.
_check
(
'control'
)
suite
=
pybut
.
suite
(
TestImport
)
if
__name__
==
'__main__'
:
pybut
.
run
(
suite
)
Event Timeline
Log In to Comment