3131from attr .validators import instance_of
3232
3333from renku .core import errors
34+ from renku .core .models .provenance .agents import Person
3435from renku .core .models .provenance .entities import Entity
3536from renku .core .utils .datetime8601 import parse_date
3637from renku .core .utils .doi import extract_doi , is_doi
@@ -53,35 +54,17 @@ def _extract_doi(value):
5354 return value
5455
5556
56- @jsonld .s (
57- type = 'schema:Person' ,
58- context = {'schema' : 'http://schema.org/' },
59- slots = True ,
60- )
61- class Creator (object ):
57+ class Creator (Person ):
6258 """Represent the creator of a resource."""
6359
64- client = attr .ib (default = None , kw_only = True )
65-
6660 affiliation = jsonld .ib (
6761 default = None , kw_only = True , context = 'schema:affiliation'
6862 )
6963
70- email = jsonld .ib (default = None , kw_only = True , context = 'schema:email' )
71-
7264 alternate_name = jsonld .ib (
7365 default = None , kw_only = True , context = 'schema:alternateName'
7466 )
7567
76- name = jsonld .ib (
77- default = None ,
78- kw_only = True ,
79- validator = instance_of (str ),
80- context = 'schema:name'
81- )
82-
83- _id = jsonld .ib (kw_only = True , context = '@id' )
84-
8568 @property
8669 def short_name (self ):
8770 """Gives full name in short form."""
@@ -95,14 +78,6 @@ def short_name(self):
9578
9679 return '{0}.{1}' .format ('.' .join (initials ), last_name )
9780
98- @email .validator
99- def check_email (self , attribute , value ):
100- """Check that the email is valid."""
101- if self .email and not (
102- isinstance (value , str ) and re .match (r'[^@]+@[^@]+\.[^@]+' , value )
103- ):
104- raise ValueError ('Email address is invalid.' )
105-
10681 @classmethod
10782 def from_git (cls , git ):
10883 """Create an instance from a Git repo."""
@@ -129,18 +104,6 @@ def from_git(cls, git):
129104
130105 return cls (name = name , email = email )
131106
132- @classmethod
133- def from_commit (cls , commit ):
134- """Create an instance from a Git commit."""
135- return cls (name = commit .author .name , email = commit .author .email )
136-
137- @_id .default
138- def default_id (self ):
139- """Set the default id."""
140- if self .email :
141- return 'mailto:{email}' .format (email = self .email )
142- return '_:{}' .format (str (uuid .uuid4 ()))
143-
144107 def __attrs_post_init__ (self ):
145108 """Finish object initialization."""
146109 # handle the case where ids were improperly set
0 commit comments