Skip to content

Commit

Permalink
pycodestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco committed Jul 28, 2023
1 parent 874df5c commit 1f4d139
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 2 deletions.
Empty file removed site/__init__.py
Empty file.
1 change: 0 additions & 1 deletion site/cds_rdm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def delete_record(recid):
A command to delete a record by giving the pid to delete. **This is a temporary solution** until the deletion mechanism is implemented in service layer.
Usage: invenio cds-admin delete -r <recid>
"""

# Record
(
record_pid,
Expand Down
2 changes: 2 additions & 0 deletions site/cds_rdm/migration/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

@click.group()
def migration():
"""Migration CLI."""
pass


@migration.command()
def run():
"""Run."""
runner = Runner(
stream_definitions=[
RecordStreamDefinition,
Expand Down
6 changes: 6 additions & 0 deletions site/cds_rdm/migration/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@


class LegacyExtract(Extract):
"""LegacyExtract."""

def __init__(self, dirpath):
"""Constructor."""
self.dirpath = Path(dirpath).absolute()

def run(self):
"""Run."""
files = [
f
for f in listdir(self.dirpath)
Expand All @@ -37,11 +40,14 @@ def run(self):


class LegacyUserExtract(Extract):
"""LegacyUserExtract."""

def __init__(self, filepath):
"""Constructor."""
self.filepath = Path(filepath).absolute()

def run(self):
"""Run."""
with open(self.filepath, "r") as dump_file:
data = json.load(dump_file)
with click.progressbar(data) as records:
Expand Down
3 changes: 3 additions & 0 deletions site/cds_rdm/migration/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@


class CDSRecordCopyLoad(RDMRecordCopyLoad):
"""CDSRecordCopyLoad."""

def __init__(self, communities_cache, db_uri, tmp_dir):
"""Constructor."""
tmp_dir = Path(tmp_dir).absolute()
super().__init__(communities_cache, db_uri, tmp_dir)
2 changes: 2 additions & 0 deletions site/cds_rdm/migration/transform/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def transform(self, entry):


class CDSToRDMRecordTransform(RDMRecordTransform):
"""CDSToRDMRecordTransform."""

def _community_id(self, entry, record):
communities = record.get("communities")
if communities:
Expand Down
11 changes: 11 additions & 0 deletions site/cds_rdm/migration/transform/user_transform.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2023 CERN.
#
# CDS-RDM is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

"""CDS-RDM transform user."""

from datetime import datetime

from invenio_rdm_migrator.streams.users import UserEntry, UserTransform


class CDSUserTransform(UserTransform):
"""CDSUserTransform."""

def _user(self, entry):
"""Transform the user."""
return CDSUserEntry().transform(entry)
Expand Down
3 changes: 2 additions & 1 deletion site/cds_rdm/migration/transform/xml_processing/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def creators(self, key, value):
@for_each_value
@require(["a"])
def contributors(self, key, value):
"""Translates contributors."""
return creators(self, key, value)


Expand Down Expand Up @@ -125,7 +126,6 @@ def languages(self, key, value):
@filter_list_values
def subjects(self, key, value):
"""Translates languages fields."""

_subjects = self.get("subjects", [])
subject_a = value.get("a")
subject_e = value.get("e")
Expand All @@ -143,4 +143,5 @@ def subjects(self, key, value):
@model.over("communities", "^980__")
@require(["a"])
def communities(self, key, value):
"""Translates communities."""
return ["cms-notes"]
2 changes: 2 additions & 0 deletions site/cds_rdm/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


def confirm_registration_form(*args, **kwargs):
"""Confirm form."""
Form = confirm_register_form_preferences_factory(_security.confirm_register_form)

class _Form(Form):
Expand Down Expand Up @@ -71,6 +72,7 @@ def cern_groups_handler(remote, resp):


def cern_info_serializer(remote, resp, token_user_info, user_info):
"""Info serializer."""
user_info = user_info or {}

email = token_user_info["email"]
Expand Down

0 comments on commit 1f4d139

Please sign in to comment.