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
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
limbra
limbra
Commits
b8a7f358
Commit
b8a7f358
authored
Sep 21, 2015
by
LE GAC Renaud
Browse files
Rename the method Automaton.select_record as check_record.
parent
f9bfd171
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
320 additions
and
300 deletions
+320
-300
modules/harvest_tools/articles.py
modules/harvest_tools/articles.py
+48
-47
modules/harvest_tools/automaton.py
modules/harvest_tools/automaton.py
+16
-10
modules/harvest_tools/notes.py
modules/harvest_tools/notes.py
+37
-37
modules/harvest_tools/preprints.py
modules/harvest_tools/preprints.py
+53
-50
modules/harvest_tools/proceedings.py
modules/harvest_tools/proceedings.py
+45
-43
modules/harvest_tools/reports.py
modules/harvest_tools/reports.py
+37
-34
modules/harvest_tools/talks.py
modules/harvest_tools/talks.py
+41
-39
modules/harvest_tools/thesis.py
modules/harvest_tools/thesis.py
+43
-40
No files found.
modules/harvest_tools/articles.py
View file @
b8a7f358
...
...
@@ -16,7 +16,7 @@ MSG_TRANSFORM_PREPRINT = "Transform the preprint into an article"
class
Articles
(
Automaton
):
"""
Publications tool
for articles.
"""
Automaton
for articles.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -170,6 +170,53 @@ class Articles(Automaton):
return
(
rec_id
,
1
)
def
check_record
(
self
,
record
):
"""Check the content of the article in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select article record"
try
:
self
.
check
.
clean_erratum
(
record
)
if
not
record
.
is_published
():
self
.
logs
[
-
1
].
reject
(
MSG_NO_EDITOR
,
record
.
year
())
return
False
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
paper_reference
(
record
)
self
.
check
.
format_editor
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load an article in the database.
The method assume that erratum are removed.
...
...
@@ -262,49 +309,3 @@ class Articles(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the C{record} is published.
@type record: L{Record}
@param record:
@rtype: bool
"""
if
not
Automaton
.
select_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select article record"
try
:
self
.
check
.
clean_erratum
(
record
)
if
not
record
.
is_published
():
self
.
logs
[
-
1
].
reject
(
MSG_NO_EDITOR
,
record
.
year
())
return
False
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
paper_reference
(
record
)
self
.
check
.
format_editor
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
modules/harvest_tools/automaton.py
View file @
b8a7f358
...
...
@@ -364,21 +364,28 @@ class Automaton(object):
return
get_create_id
(
self
.
db
.
publishers
,
abbreviation
=
value
)
def
select_record
(
self
,
record
):
"""C{True} when the C{record} is selected.
This method check and format the author field.
def
check_record
(
self
,
record
):
"""Check the content of the record in order to fix non conformities.
Return False when a non conformities has been found and can not be
corrected.
@note:
Th
e checks depend on the type of publications and have to be
@note:
Som
e checks depend on the type of publications and have to be
implemented in inherited class.
@note: The order of the checks matter. It should be oai,
temporary record, authors, my authors and then a series of checks
specific to the publication type.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
self
.
dbg
:
print
"
select record and check / format auth
or
s
"
print
"
check rec
or
d
"
try
:
self
.
check
.
temporary_record
(
record
)
...
...
@@ -386,7 +393,7 @@ class Automaton(object):
self
.
check
.
format_authors
(
record
,
format_author_fr
)
self
.
check
.
collaboration
(
record
)
except
Base
Exception
as
e
:
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
...
...
@@ -557,10 +564,9 @@ class Automaton(object):
if
not
match
:
self
.
logs
[
-
1
].
reject
(
MSG_WELL_FORM_OAI
,
record
.
year
())
# additional selection stage
# at this step the validity of the record is checked
# and non-conformities are repaired
if
not
self
.
select_record
(
record
):
# check that the record is well formed
# repair non-conformity as far as possible
if
not
self
.
check_record
(
record
):
continue
if
self
.
dbg
:
...
...
modules/harvest_tools/notes.py
View file @
b8a7f358
...
...
@@ -12,9 +12,45 @@ from plugin_dbui import get_id, UNDEF_ID
class
Notes
(
Automaton
):
"""
Publications tool
for notes.
"""
Automaton
for notes.
"""
def
check_record
(
self
,
record
):
"""Check the content of the note in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select note record"
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load a public note in the database.
...
...
@@ -64,39 +100,3 @@ class Notes(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the note is valid.
@type record: L{Record}
@param record:
@rtype: bool
"""
if
not
Automaton
.
select_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select note record"
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
modules/harvest_tools/preprints.py
View file @
b8a7f358
...
...
@@ -18,9 +18,61 @@ MSG_PREPRINT_NO_NUMBER = "Reject no preprint number"
class
Preprints
(
Automaton
):
"""
Publications tool
for preprints.
"""
Automaton
for preprints.
"""
def
check_record
(
self
,
record
):
"""Check the content of the preprint in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select preprint record"
if
record
.
is_published
():
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_PAPER
,
record
.
year
())
return
False
if
isinstance
(
record
,
RecordConf
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_CONFERENCE
,
record
.
year
())
return
False
if
isinstance
(
record
,
RecordThesis
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_THESIS
,
record
.
year
())
return
False
if
not
record
.
preprint_number
():
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_NO_NUMBER
,
record
.
year
())
return
False
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load a preprint in the database.
...
...
@@ -78,52 +130,3 @@ class Preprints(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the preprint is valid.
@type record: L{Record}
@param record:
"""
if
not
Automaton
.
select_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select preprint record"
if
record
.
is_published
():
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_PAPER
,
record
.
year
())
return
False
if
isinstance
(
record
,
RecordConf
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_CONFERENCE
,
record
.
year
())
return
False
if
isinstance
(
record
,
RecordThesis
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_THESIS
,
record
.
year
())
return
False
if
not
record
.
preprint_number
():
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_NO_NUMBER
,
record
.
year
())
return
False
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
modules/harvest_tools/proceedings.py
View file @
b8a7f358
...
...
@@ -12,9 +12,53 @@ from plugin_dbui import get_id, UNDEF_ID
class
Proceedings
(
Automaton
):
"""
Publications tool
for conference proceedings.
"""
Automaton
for conference proceedings.
"""
def
check_record
(
self
,
record
):
"""Check the content of the proceeding in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select and check proceeding record"
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
is_conference
(
record
)
self
.
check
.
conference
(
record
)
self
.
check
.
clean_erratum
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
paper_reference
(
record
)
self
.
check
.
format_editor
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load a conference proceeding in the database.
...
...
@@ -108,45 +152,3 @@ class Proceedings(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the C{record} is contains conference data.
@type record: L{Record}
@param record:
@rtype: bool
"""
if
not
Automaton
.
select_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select and check proceeding record"
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
is_conference
(
record
)
self
.
check
.
conference
(
record
)
self
.
check
.
clean_erratum
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
paper_reference
(
record
)
self
.
check
.
format_editor
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
modules/harvest_tools/reports.py
View file @
b8a7f358
...
...
@@ -15,9 +15,45 @@ MSG_REPORT_NO_NUMBER = "Reject no report number"
class
Reports
(
Automaton
):
"""
Publications tool
for reports to committee.
"""
Automaton
for reports to committee.
"""
def
check_record
(
self
,
record
):
"""Check the content of the report in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select report record"
if
not
record
.
report_number
():
self
.
logs
[
-
1
].
reject
(
MSG_REPORT_NO_NUMBER
,
record
.
year
())
return
False
try
:
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load a report in the database.
...
...
@@ -85,36 +121,3 @@ class Reports(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the report is valid.
@type record: L{Record}
@param record:
"""
if
not
Automaton
.
select_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select report record"
if
not
record
.
report_number
():
self
.
logs
[
-
1
].
reject
(
MSG_REPORT_NO_NUMBER
,
record
.
year
())
return
False
try
:
self
.
check
.
oai
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
modules/harvest_tools/talks.py
View file @
b8a7f358
...
...
@@ -12,9 +12,49 @@ from plugin_dbui import get_id, UNDEF_ID
class
Talks
(
Automaton
):
"""
Publications tool
for conference talks.
"""
Automaton
for conference talks.
"""
def
check_record
(
self
,
record
):
"""Check the content of the talk in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if
not
Automaton
.
check_record
(
self
,
record
):
return
False
if
self
.
dbg
:
print
"select talk record"
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
oai
(
record
)
self
.
check
.
is_conference
(
record
)
self
.
check
.
conference
(
record
)
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
.
year
())
return
False
except
Exception
as
e
:
self
.
logs
[
-
1
].
reject
(
MSG_CRASH
%
e
,
record
.
year
(),
translate
=
False
)
print
traceback
.
format_exc
()
return
False
return
True
def
load_db
(
self
,
record
):
"""Load a conference talk in the database.
...
...
@@ -76,41 +116,3 @@ class Talks(Automaton):
self
.
logs
[
-
1
].
load
(
MSG_LOAD
,
year
)
return
1
def
select_record
(
self
,
record
):
"""C{True} when the C{record} is contains conference data.
@type record: L{Record}