Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
42906b79
Commit
42906b79
authored
Jan 11, 2016
by
LE GAC Renaud
Browse files
Add the script fix_acti2com_cppm.py
parent
eff33421
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
0 deletions
+126
-0
scripts/fix_acti2com_cppm.py
scripts/fix_acti2com_cppm.py
+126
-0
No files found.
scripts/fix_acti2com_cppm.py
0 → 100644
View file @
42906b79
# -*- coding: utf-8 -*-
""" NAME
fix_acti2com_cppm
SYNOPSIS
Copy ACTI to COM for the CPPM database.
DESCRIPTION
Up to the end of 2014 a talk to a conference (COM) is transformed
into a proceeding (ACTI) when the later is published.
In 2015, the policy changes, COM and ACTI are kept as separated
publications
This script implement the new policy for the publications registered
before 2015. It mainly copy the ACTI into COM for the year from
2009 up to 2014.
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...track_publications/scripts
> ./run -S test_publications script fix_acti2com_cppm.py
> ./run -S track_publications script fix_acti2com_cppm.py
AUTHOR
R. Le Gac -- Jan 2016
"""
import
re
REG_ORIGIN
=
re
.
compile
(
"https?://([a-z\.]+)/record/(\d+)"
)
if
__name__
==
"__main__"
:
import
sys
from
argparse
import
ArgumentParser
,
FileType
from
invenio_tools
import
load_record
,
OAI_URL
from
plugin_dbui
import
CALLBACK_ERRORS
,
get_id
# command line options
parser
=
ArgumentParser
()
args
=
parser
.
parse_args
()
# get the ACTI / COM identifier
id_acti
=
get_id
(
db
.
categories
,
code
=
"ACTI"
)
id_com
=
get_id
(
db
.
categories
,
code
=
"COM"
)
# build the query
query
=
db
.
publications
.
id_categories
==
id_acti
query
&=
db
.
publications
.
year
>=
2009
query
&=
db
.
publications
.
year
<=
2014
# scan the publications table
for
row
in
db
(
query
).
select
():
data
=
row
.
as_dict
()
# skip if the the speaker is not from CPPM
if
data
[
"conference_speaker"
]
not
in
data
[
"authors_institute"
]:
continue
# remove publisher information
data
[
"id_publishers"
]
=
1
data
[
"pages"
]
=
""
data
[
"volume"
]
=
""
data
[
"submitted"
]
=
""
data
[
"publication_url"
]
=
""
data
[
"preprint"
]
=
""
# the year is the one of the conference
conference_dates
=
data
[
"conference_dates"
]
if
conference_dates
:
data
[
"year"
]
=
int
(
data
[
"conference_dates"
][
-
4
:])
else
:
print
"No conferences dates"
,
data
[
"id"
]
# change the category and the status
data
[
"id_categories"
]
=
id_com
data
[
"id_status"
]
=
1
# change the origin
val
=
data
[
"origin"
]
if
val
:
origin
=
val
.
split
(
','
)[
0
].
strip
()
match
=
REG_ORIGIN
.
match
(
origin
)
host
,
rec_id
=
match
.
group
(
1
),
match
.
group
(
2
)
proceeding
=
load_record
(
host
,
rec_id
)
talk_id
=
proceeding
.
reference_conference_talk
()
data
[
"origin"
]
=
(
OAI_URL
%
(
host
,
talk_id
)
if
talk_id
else
""
)
# insert the new record in the database
id_rec
=
data
[
"id"
],
del
data
[
"id"
]
id_new
=
db
.
publications
.
insert
(
**
data
)
print
"Copy"
,
id_rec
,
"→"
,
if
id_new
:
print
id_new
elif
CALLBACK_ERRORS
in
db
.
publications
:
print
" "
.
join
(
db
.
publications
.
_callback_errors
)
else
:
print
"???"
# commit change
rep
=
raw_input
(
"Commit change in the database? [y/N]:"
)
if
rep
==
'y'
:
print
"The database is modified."
db
.
commit
()
# close
sys
.
exit
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment