1717# limitations under the License.
1818"""Model objects representing a creator."""
1919import configparser
20- import re
21- import uuid
2220
2321import attr
24- from attr .validators import instance_of
2522
2623from renku .core import errors
24+ from renku .core .models .provenance .agents import Person
2725
2826from . import jsonld as jsonld
2927
3028
31- @jsonld .s (
32- type = 'schema:Person' ,
33- context = {'schema' : 'http://schema.org/' },
34- slots = True ,
35- )
36- class Creator (object ):
29+ class Creator (Person ):
3730 """Represent the creator of a resource."""
3831
39- client = attr .ib (default = None , kw_only = True )
40-
4132 affiliation = jsonld .ib (
4233 default = None , kw_only = True , context = 'schema:affiliation'
4334 )
4435
45- email = jsonld .ib (default = None , kw_only = True , context = 'schema:email' )
46-
4736 alternate_name = jsonld .ib (
4837 default = None , kw_only = True , context = 'schema:alternateName'
4938 )
5039
51- name = jsonld .ib (
52- default = None ,
53- kw_only = True ,
54- validator = instance_of (str ),
55- context = 'schema:name'
56- )
57-
58- _id = jsonld .ib (kw_only = True , context = '@id' )
59-
6040 @property
6141 def short_name (self ):
6242 """Gives full name in short form."""
@@ -70,14 +50,6 @@ def short_name(self):
7050
7151 return '{0}.{1}' .format ('.' .join (initials ), last_name )
7252
73- @email .validator
74- def check_email (self , attribute , value ):
75- """Check that the email is valid."""
76- if self .email and not (
77- isinstance (value , str ) and re .match (r'[^@]+@[^@]+\.[^@]+' , value )
78- ):
79- raise ValueError ('Email address is invalid.' )
80-
8153 @classmethod
8254 def from_git (cls , git ):
8355 """Create an instance from a Git repo."""
@@ -104,18 +76,6 @@ def from_git(cls, git):
10476
10577 return cls (name = name , email = email )
10678
107- @classmethod
108- def from_commit (cls , commit ):
109- """Create an instance from a Git commit."""
110- return cls (name = commit .author .name , email = commit .author .email )
111-
112- @_id .default
113- def default_id (self ):
114- """Set the default id."""
115- if self .email :
116- return 'mailto:{email}' .format (email = self .email )
117- return '_:{}' .format (str (uuid .uuid4 ()))
118-
11979 def __attrs_post_init__ (self ):
12080 """Finish object initialization."""
12181 # handle the case where ids were improperly set
0 commit comments