***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Invenio Utilities TUW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Center for Research Data Management
Invenio Utilities TUW
Commits
4c13c23a
Commit
4c13c23a
authored
3 years ago
by
Moser, Maximilian
Browse files
Options
Downloads
Patches
Plain Diff
Remove the setting of creatibutor names
parent
11edd463
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Modernization
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
invenio_utilities_tuw/cli/drafts.py
+0
-4
0 additions, 4 deletions
invenio_utilities_tuw/cli/drafts.py
invenio_utilities_tuw/cli/records.py
+0
-2
0 additions, 2 deletions
invenio_utilities_tuw/cli/records.py
invenio_utilities_tuw/cli/utils.py
+0
-25
0 additions, 25 deletions
invenio_utilities_tuw/cli/utils.py
with
0 additions
and
31 deletions
invenio_utilities_tuw/cli/drafts.py
+
0
−
4
View file @
4c13c23a
...
...
@@ -35,7 +35,6 @@ from .utils import (
get_user_by_identifier
,
patch_metadata
,
read_metadata
,
set_creatibutor_names
,
set_record_owners
,
)
...
...
@@ -106,7 +105,6 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
if
isfile
(
metadata_path
):
metadata
=
read_metadata
(
metadata_path
)
metadata
=
set_creatibutor_names
(
metadata
)
draft
=
create_record_from_metadata
(
metadata
,
identity
,
vanity_pid
=
vanity_pid
)
recid
=
draft
[
"
id
"
]
draft
.
files
.
enabled
=
False
...
...
@@ -119,7 +117,6 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
raise
Exception
(
"
metadata file does not exist: %s
"
%
metadata_file_path
)
metadata
=
read_metadata
(
metadata_file_path
)
metadata
=
set_creatibutor_names
(
metadata
)
draft
=
create_record_from_metadata
(
metadata
,
identity
)
recid
=
draft
[
"
id
"
]
draft
.
files
.
enabled
=
True
...
...
@@ -218,7 +215,6 @@ def update_draft(metadata_file, pid, pid_type, user, patch, owners):
owners
=
[
get_user_by_identifier
(
owner
)
for
owner
in
owners
]
set_record_owners
(
draft
,
owners
)
metadata
=
set_creatibutor_names
(
metadata
)
service
.
update_draft
(
id_
=
pid
,
identity
=
identity
,
data
=
metadata
)
click
.
secho
(
pid
,
fg
=
"
green
"
)
...
...
This diff is collapsed.
Click to expand it.
invenio_utilities_tuw/cli/records.py
+
0
−
2
View file @
4c13c23a
...
...
@@ -31,7 +31,6 @@ from .utils import (
get_object_uuid
,
get_user_by_identifier
,
patch_metadata
,
set_creatibutor_names
,
set_record_owners
,
)
...
...
@@ -131,7 +130,6 @@ def update_record(metadata_file, pid, pid_type, user, patch, owners, direct):
record_data
=
service
.
read
(
id_
=
pid
,
identity
=
identity
).
data
.
copy
()
metadata
=
patch_metadata
(
record_data
,
metadata
)
metadata
=
set_creatibutor_names
(
metadata
)
if
direct
:
record
=
service
.
read
(
id_
=
pid
,
identity
=
identity
).
_record
record
.
update
(
metadata
)
...
...
This diff is collapsed.
Click to expand it.
invenio_utilities_tuw/cli/utils.py
+
0
−
25
View file @
4c13c23a
...
...
@@ -142,31 +142,6 @@ def set_record_owners(record, owners, commit=True):
db
.
session
.
commit
()
def
_set_creatibutor_name
(
creatibutor
):
"""
Set the name from the given_name and family_name from the creator/contributor.
"""
creatibutor
=
creatibutor
.
get
(
"
person_or_org
"
,
{})
name
=
creatibutor
.
get
(
"
name
"
)
if
not
name
:
given_name
=
creatibutor
.
get
(
"
given_name
"
)
family_name
=
creatibutor
.
get
(
"
family_name
"
)
if
given_name
and
family_name
:
creatibutor
[
"
name
"
]
=
"
{}, {}
"
.
format
(
family_name
,
given_name
)
def
set_creatibutor_names
(
record_metadata
):
"""
Set the name field for each creator and contributor if they
'
re not set.
"""
metadata
=
record_metadata
.
copy
()
for
creator
in
metadata
.
get
(
"
metadata
"
,
{}).
get
(
"
creators
"
,
[]):
_set_creatibutor_name
(
creator
)
for
contributor
in
metadata
.
get
(
"
metadata
"
,
{}).
get
(
"
contributors
"
,
[]):
_set_creatibutor_name
(
contributor
)
return
metadata
def
similarity
(
a
:
str
,
b
:
str
)
->
float
:
"""
Calculate the similarity between two strings.
"""
return
SequenceMatcher
(
None
,
a
,
b
).
ratio
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment