***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Invenio Utilities
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Merge requests
!1
Updates
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Updates
dev
into
master
Overview
0
Commits
15
Pipelines
0
Changes
10
Merged
Moser, Maximilian
requested to merge
dev
into
master
2 years ago
Overview
0
Commits
15
Pipelines
0
Changes
10
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
3e2a6b2f
15 commits,
2 years ago
10 files
+
668
−
103
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
Search (e.g. *.vue) (Ctrl+P)
record-migration/migration/dec20-to-feb21.py
0 → 100755
+
99
−
0
Options
#!/usr/bin/env python3
import
json
import
os
import
sys
def
map_identifiers
(
identifiers
):
ret
=
[]
for
k
in
identifiers
:
val
=
{
"
identifier
"
:
identifiers
[
k
],
"
scheme
"
:
k
,
}
ret
.
append
(
val
)
return
ret
def
map_affiliation
(
affiliation
):
return
{
"
name
"
:
affiliation
[
"
name
"
],
"
identifiers
"
:
map_identifiers
(
affiliation
.
get
(
"
identifiers
"
,
{})),
}
def
map_creatibutor
(
creatibutor
,
default_role
=
"
editor
"
):
return
{
"
role
"
:
creatibutor
.
get
(
"
role
"
,
default_role
),
"
affiliations
"
:
[
map_affiliation
(
aff
)
for
aff
in
creatibutor
[
"
affiliations
"
]],
"
person_or_org
"
:
{
"
type
"
:
creatibutor
[
"
type
"
],
"
name
"
:
creatibutor
.
get
(
"
name
"
),
"
given_name
"
:
creatibutor
.
get
(
"
given_name
"
),
"
family_name
"
:
creatibutor
.
get
(
"
family_name
"
),
"
identifiers
"
:
map_identifiers
(
creatibutor
.
get
(
"
identifiers
"
,
[])),
},
}
def
map_right
(
right
):
return
{
"
link
"
:
right
.
get
(
"
uri
"
),
"
id
"
:
right
.
get
(
"
identifier
"
),
"
title
"
:
right
.
get
(
"
rights
"
),
}
def
map_location
(
location
):
ret
=
location
.
copy
()
ret
[
"
identifiers
"
]
=
map_identifiers
(
location
.
get
(
"
identifiers
"
,
[]))
return
ret
# - - - - - - - - - - - #
# start doing the stuff #
# - - - - - - - - - - - #
directory
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
1
else
"
outputs
"
for
f
in
os
.
listdir
(
directory
):
ff
=
os
.
path
.
join
(
directory
,
f
)
recid
,
ext
=
os
.
path
.
splitext
(
f
)
if
ext
.
lower
()
!=
"
.json
"
:
continue
with
open
(
ff
,
"
r
"
)
as
data_file
:
data
=
json
.
load
(
data_file
)
new
=
data
.
copy
()
for
k
in
[
"
id
"
,
"
pid
"
,
"
conceptid
"
,
"
conceptpid
"
]:
new
.
pop
(
k
,
None
)
new
[
"
metadata
"
][
"
contributors
"
]
=
[
map_creatibutor
(
c
)
for
c
in
data
[
"
metadata
"
].
get
(
"
contributors
"
,
[])
]
new
[
"
metadata
"
][
"
creators
"
]
=
[
map_creatibutor
(
c
)
for
c
in
data
[
"
metadata
"
][
"
creators
"
]
]
new
[
"
metadata
"
][
"
rights
"
]
=
[
map_right
(
right
)
for
right
in
data
[
"
metadata
"
].
get
(
"
rights
"
,
[])
]
new
[
"
metadata
"
][
"
locations
"
]
=
[
map_location
(
location
)
for
location
in
data
[
"
metadata
"
].
get
(
"
locations
"
,
[])
]
# TODO: check why this is the case
new
[
"
metadata
"
].
pop
(
"
references
"
,
None
)
# because subjects aren't supported right now (TODO: check)
new
[
"
metadata
"
].
pop
(
"
subjects
"
,
None
)
# because the identifiers may have used weird schemes in both cases
new
[
"
metadata
"
].
pop
(
"
locations
"
,
None
)
new
[
"
metadata
"
].
pop
(
"
funding
"
,
None
)
new
[
"
access
"
]
=
{
"
record
"
:
"
public
"
,
"
files
"
:
"
public
"
,
"
owned_by
"
:
[{
"
user
"
:
"
1
"
}]}
ff
=
os
.
path
.
join
(
directory
,
recid
+
"
.migrated
"
)
with
open
(
ff
,
"
w
"
)
as
data_file
:
json
.
dump
(
new
,
data_file
)
Loading