Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99158572
reg_openoffice.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 21, 20:06
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Jan 23, 20:06 (2 d)
Engine
blob
Format
Raw Data
Handle
23723155
Attached To
R3596 pybliographer
reg_openoffice.py
View Options
# regression testsuite for OpenOffice.org integration
from
Pyblio.Cite.WP.OpenOffice
import
OOo
from
Pyblio.Format
import
B
,
one
from
Pyblio
import
Registry
,
Attribute
,
Store
Registry
.
load_default_settings
()
s
=
Registry
.
getSchema
(
'org.pybliographer/bibtex/0.1'
)
db
=
Store
.
get
(
'memory'
)
.
dbcreate
(
None
,
s
)
style
=
u'This has key '
+
B
[
one
(
'id'
)]
formatter
=
style
(
db
)
# tests begin here
oo
=
OOo
()
oo
.
connect
()
oo
.
text
.
setString
(
u''
)
refs
=
[(
1
,
'a'
,
'bibtex-a'
),
(
2
,
'b'
,
'bibtex-b'
)]
oo
.
cite
(
refs
,
None
)
# check that the citations have been inserted in the document
r
=
oo
.
text
.
getString
()
assert
r
==
u'[a][b]'
,
repr
(
r
)
# check that the document can return the existing citations
r
=
oo
.
fetch
()
assert
r
==
refs
,
repr
(
r
)
# create the bibliography
insert
=
oo
.
update_biblio
()
insert
.
begin_biblio
()
for
uid
,
key
,
extra
in
refs
:
insert
.
begin_reference
(
key
)
r
=
Store
.
Record
()
r
.
add
(
'id'
,
key
,
Attribute
.
ID
)
insert
(
formatter
(
r
))
insert
.
end_reference
(
key
)
insert
.
end_biblio
()
r
=
oo
.
text
.
getString
()
assert
r
==
u'''
\
[a][b]
[a]
\xa0
This has key a
[b]
\xa0
This has key b
'''
,
r
# update the bibliography
insert
=
oo
.
update_biblio
()
insert
.
begin_biblio
()
reverse
=
refs
[:]
reverse
.
reverse
()
for
uid
,
key
,
extra
in
reverse
:
insert
.
begin_reference
(
key
)
r
=
Store
.
Record
()
r
.
add
(
'id'
,
key
,
Attribute
.
ID
)
insert
(
formatter
(
r
))
insert
.
end_reference
(
key
)
insert
.
end_biblio
()
r
=
oo
.
text
.
getString
()
assert
r
==
u'''
\
[a][b]
[b]
\xa0
This has key b
[a]
\xa0
This has key a
'''
,
r
# update the labels
oo
.
update_keys
({
1
:
u'b'
,
2
:
u'a'
})
r
=
oo
.
text
.
getString
()
assert
r
==
u'''
\
[b][a]
[b]
\xa0
This has key b
[a]
\xa0
This has key a
'''
,
r
Event Timeline
Log In to Comment