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
7318fcce
Commit
7318fcce
authored
Jun 07, 2017
by
LE GAC Renaud
Browse files
Update Automatons and controller to remove depency to format_author_fr.
parent
e22f1a62
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
28 additions
and
119 deletions
+28
-119
controllers/harvest.py
controllers/harvest.py
+2
-4
docs/api/generated/harvest_tools.base.format_author_fr.rst
docs/api/generated/harvest_tools.base.format_author_fr.rst
+0
-6
docs/api/harvester.rst
docs/api/harvester.rst
+0
-1
modules/harvest_tools/__init__.py
modules/harvest_tools/__init__.py
+0
-1
modules/harvest_tools/articles.py
modules/harvest_tools/articles.py
+3
-5
modules/harvest_tools/base.py
modules/harvest_tools/base.py
+0
-54
modules/harvest_tools/notes.py
modules/harvest_tools/notes.py
+3
-3
modules/harvest_tools/preprints.py
modules/harvest_tools/preprints.py
+3
-3
modules/harvest_tools/proceedings.py
modules/harvest_tools/proceedings.py
+3
-3
modules/harvest_tools/reports.py
modules/harvest_tools/reports.py
+4
-6
modules/harvest_tools/talks.py
modules/harvest_tools/talks.py
+3
-3
modules/harvest_tools/thesis.py
modules/harvest_tools/thesis.py
+3
-3
tests/harvest_tools/test_harvest_tools_functions.py
tests/harvest_tools/test_harvest_tools_functions.py
+4
-27
No files found.
controllers/harvest.py
View file @
7318fcce
...
...
@@ -10,8 +10,6 @@ from harvest_tools import (build_harvester_tool,
CheckAndFix
,
CheckException
,
DRY_RUN
,
format_author_fr
,
family_name_fr
,
search_synonym
,
ToolException
)
from
invenio_tools
import
(
load_record
,
...
...
@@ -158,12 +156,12 @@ def edit_insert():
# authors
try
:
check
.
authors
(
record
)
check
.
format_authors
(
record
,
f
ormat_author_fr
)
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
check
.
my_affiliation
(
record
,
selector
.
id_projects
,
selector
.
id_teams
)
check
.
get_my_authors
(
record
,
cmpFct
=
family_name_fr
)
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
:
pass
...
...
docs/api/generated/harvest_tools.base.format_author_fr.rst
deleted
100644 → 0
View file @
e22f1a62
harvest_tools.base.format_author_fr
===================================
.. currentmodule:: harvest_tools.base
.. autofunction:: format_author_fr
\ No newline at end of file
docs/api/harvester.rst
View file @
7318fcce
...
...
@@ -50,7 +50,6 @@ Helper functions
:toctree: generated/
~base.family_name_fr
~base.format_author_fr
~base.learn_my_authors
~base.search_synonym
...
...
modules/harvest_tools/__init__.py
View file @
7318fcce
...
...
@@ -11,7 +11,6 @@ from base import (DRY_RUN,
MSG_NO_ENTRY
,
MSG_TOOMANY_SYNONYM
,
family_name_fr
,
format_author_fr
,
search_synonym
)
from
automaton
import
Automaton
...
...
modules/harvest_tools/articles.py
View file @
7318fcce
...
...
@@ -6,9 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
(
family_name_fr
,
format_author_fr
,
learn_my_authors
,
from
base
import
(
learn_my_authors
,
MSG_CRASH
,
MSG_FIX_ORIGIN
,
MSG_IN_DB
,
...
...
@@ -63,8 +61,8 @@ class Articles(Automaton):
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
modules/harvest_tools/base.py
View file @
7318fcce
...
...
@@ -3,7 +3,6 @@
"""
from
exception
import
ToolException
from
invenio_tools
import
REG_AUTHOR
from
plugin_dbui
import
get_id
,
UNDEF_ID
...
...
@@ -31,59 +30,6 @@ def family_name_fr(full_name):
return
full_name
[
full_name
.
find
(
' '
)
+
1
:]
def
format_author_fr
(
name
):
"""Format the author name according to French typographic rules.
Note:
The name stays unchanged when the formatting failed.
Args:
name (unicode): full name. Possible patterns are:
* ``Family, L``
* ``Family, L.``
* ``Family, P L``
* ``Family, P.L.``
* ``Family, P.-L.``
* ``Family, M -H``
* ``Family Name, J``
* ``Family-Name, J``
* ``Family, F Name``
* ``Family, First``
* ...
Returns:
unicode: the author name encode as ``J.-P. Doe``.
"""
# protection
if
name
==
''
or
name
is
None
:
return
name
# decode the name Family, First + many variant
# group(1) family name
# group(2) first name
# group(3) second part of the first name
match
=
REG_AUTHOR
.
match
(
name
)
# reformat the name as L. Family
# or keep it as it is
if
match
:
if
match
.
group
(
3
):
tpl
=
(
match
.
group
(
2
)[
0
],
match
.
group
(
3
)[
0
],
match
.
group
(
1
))
result
=
'%s.-%s. %s'
%
tpl
else
:
result
=
'%s. %s'
%
(
match
.
group
(
2
)[
0
],
match
.
group
(
1
))
else
:
result
=
name
# avoid author name in upper case (R. LE FOO --> R. Le Foo)
result
=
result
.
title
()
return
result
def
learn_my_authors
(
db
,
authors
=
None
,
id_project
=
None
,
...
...
modules/harvest_tools/notes.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
plugin_dbui
import
UNDEF_ID
...
...
@@ -36,8 +36,8 @@ class Notes(Automaton):
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
modules/harvest_tools/preprints.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
invenio_tools
import
RecordConf
,
RecordThesis
from
plugin_dbui
import
UNDEF_ID
...
...
@@ -59,8 +59,8 @@ class Preprints(Automaton):
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
modules/harvest_tools/proceedings.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
plugin_dbui
import
UNDEF_ID
...
...
@@ -45,8 +45,8 @@ class Proceedings(Automaton):
self
.
check
.
publisher
(
record
)
self
.
check
.
paper_reference
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
modules/harvest_tools/reports.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
plugin_dbui
import
get_id
,
UNDEF_ID
,
UNKNOWN
...
...
@@ -43,8 +43,8 @@ class Reports(Automaton):
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
@@ -80,9 +80,7 @@ class Reports(Automaton):
# allow undefined institute authors
try
:
self
.
check
.
my_authors
(
record
,
reference
=
self
.
_my_author_list
(
record
),
cmpFct
=
family_name_fr
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
authors_institute
=
record
.
my_authors
except
CheckException
:
...
...
modules/harvest_tools/talks.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
plugin_dbui
import
UNDEF_ID
...
...
@@ -40,8 +40,8 @@ class Talks(Automaton):
self
.
check
.
submitted
(
record
)
self
.
check
.
year
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
modules/harvest_tools/thesis.py
View file @
7318fcce
...
...
@@ -7,7 +7,7 @@ import traceback
from
automaton
import
Automaton
from
base
import
family_name_fr
,
format_author_fr
,
MSG_CRASH
,
MSG_LOAD
from
base
import
MSG_CRASH
,
MSG_LOAD
from
checkandfix
import
CheckException
from
invenio_tools
import
RecordThesis
from
plugin_dbui
import
get_id
,
UNDEF_ID
...
...
@@ -40,8 +40,8 @@ class Thesis(Automaton):
self
.
check
.
year
(
record
)
self
.
check
.
format_universities
(
record
)
self
.
check
.
format_authors
(
record
,
f
ormat_author_fr
)
self
.
check
.
get_my_authors
(
record
,
family_name_fr
)
self
.
check
.
format_authors
(
record
,
f
mt
=
"F. Last"
)
self
.
check
.
get_my_authors
(
record
,
sort
=
True
)
except
CheckException
as
e
:
self
.
logs
[
-
1
].
reject
(
e
,
record
=
record
)
...
...
tests/harvest_tools/test_harvest_tools_functions.py
View file @
7318fcce
...
...
@@ -6,7 +6,7 @@ import pytest
from
gluon
import
current
from
harvest_tools
import
format_author_fr
,
search_synonym
,
ToolException
from
harvest_tools
import
search_synonym
,
ToolException
from
invenio_tools
import
load_record
...
...
@@ -20,36 +20,13 @@ def test_author_type():
assert
type
(
author
)
==
unicode
@
pytest
.
mark
.
parametrize
(
"value, expected"
,
[
(
u
"Aaij, Roel"
,
u
"R. Aaij"
),
(
u
"Le Gac, Renaud"
,
u
"R. Le Gac"
),
(
u
"Le Gac, R."
,
u
"R. Le Gac"
),
(
u
"Le Gac, R"
,
u
"R. Le Gac"
),
(
u
"Perrin-Terrin, Mathieu"
,
u
"M. Perrin-Terrin"
),
(
u
"Perrin-Terrin, M."
,
u
"M. Perrin-Terrin"
),
(
u
"Perrin-Terrin, M"
,
u
"M. Perrin-Terrin"
),
(
u
"Schune, Marie-Hélène"
,
u
"M.-H. Schune"
),
(
u
"Schune, Marie-Helene"
,
u
"M.-H. Schune"
),
(
u
"Schune, Marie Helene"
,
u
"M.-H. Schune"
),
(
u
"Schune, M.H."
,
u
"M.-H. Schune"
),
(
u
"Schune, M.-H."
,
u
"M.-H. Schune"
),
(
u
"Schune, M. -H."
,
u
"M.-H. Schune"
),
(
u
"Schune, M-H"
,
u
"M.-H. Schune"
),
(
u
"Schune, M -H"
,
u
"M.-H. Schune"
)
])
def
test_format_author
(
value
,
expected
):
print
value
assert
type
(
value
)
==
unicode
assert
format_author_fr
(
value
)
==
expected
def
test_search_synonym
():
db
=
current
.
db
# collaboration ANTARES, TANAMI (
should not be
defined as
a
synonym)
# collaboration ANTARES, TANAMI (defined as synonym
in the db
)
record
=
load_record
(
"inspirehep.net"
,
1342250
)
with
pytest
.
raises
(
ToolExcep
tion
)
:
search_synonym
(
db
.
collaborations
,
"collaboration"
,
record
.
collaboration
())
colid
=
search_synonym
(
db
.
collaborations
,
"collaboration"
,
record
.
collabora
tion
()
)
assert
colid
==
2
# collaboration = ANTARES (defined as synonym in the db))
record
=
load_record
(
"inspirehep.net"
,
718872
)
...
...
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