diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,4 +1,4 @@ swh.storage >= 0.0.163 -swh.model >= 0.0.59 +swh.model >= 0.0.60 swh.scheduler >= 0.0.39 swh.loader.core >= 0.0.80 diff --git a/swh/loader/svn/converters.py b/swh/loader/svn/converters.py --- a/swh/loader/svn/converters.py +++ b/swh/loader/svn/converters.py @@ -5,12 +5,9 @@ from typing import Any, Dict, List, Optional, Union -from email import utils - from swh.model.model import ( Person, Revision, RevisionType, TimestampWithTimezone ) -from swh.loader.package.utils import EMPTY_AUTHOR from .utils import strdate_to_timestamp @@ -34,7 +31,7 @@ ) -def svn_author_to_swh_person(author: Union[str, bytes]) -> Person: +def svn_author_to_swh_person(author: Union[None, str, bytes]) -> Person: """Convert an svn author to an swh person. Default policy: No information is added. @@ -45,22 +42,7 @@ a Person """ - # TODO: Align this function and move it up as library helper function - if not author: - return EMPTY_AUTHOR - - if isinstance(author, str): - author = author.encode('utf-8') - - if b'<' in author and b'>' in author: - name, email = utils.parseaddr(author.decode('utf-8')) - return Person( - fullname=author, - name=name.encode('utf-8'), - email=email.encode('utf-8') - ) - - return Person(fullname=author, name=author, email=None) + return Person.from_address(author or b'') def build_swh_revision( diff --git a/swh/loader/svn/svn.py b/swh/loader/svn/svn.py --- a/swh/loader/svn/svn.py +++ b/swh/loader/svn/svn.py @@ -106,19 +106,11 @@ def convert_commit_author(self, author): """Convert the commit author into an swh person. - The user becomes a dictionary of the form:: - - { - name: author, - email: '', - fullname: author - } - Args: author (str): the commit author to convert. Returns: - The transformed author as dict. + Person: a model object """ return converters.svn_author_to_swh_person(author)