@@ -29,22 +29,22 @@ def __init__(
2929
3030 See [somesy.core.writer.ProjectMetadataWriter.__init__][].
3131 """
32- mappings : FieldKeyMapping = None
33- # {
34- # "name": ["title"],
35- # "description": ["abstract"],
36- # "homepage": ["url"],
37- # "repository": ["repository-code"],
38- # "documentation": IgnoreKey(),
39- # "maintainers": ["contact"],
40- # }
32+ mappings : FieldKeyMapping = {
33+ "year" : ["inceptionYear" ],
34+ "license" : ["licenses" , "license" ],
35+ "homepage" : ["url" ],
36+ "project_slug" : ["artifactId" ],
37+ "authors" : ["developers" , "developer" ],
38+ "contributors" : ["contributors" , "contributor" ],
39+ }
4140 super ().__init__ (
4241 path , create_if_not_exists = create_if_not_exists , direct_mappings = mappings
4342 )
4443
4544 def _init_new_file (self ):
4645 """Initialize new pom.xml file."""
4746 pom = XMLProxy (ET .Element ("project" , POM_ROOT_ATRS ))
47+ pom ["properties" ] = {"info.versionScheme" : "semver-spec" }
4848 pom .write (self .path , default_namespace = POM_URL )
4949
5050 def _load (self ):
@@ -63,9 +63,24 @@ def save(self, path: Optional[Path] = None) -> None:
6363 @staticmethod
6464 def _from_person (person : Person ):
6565 """Convert project metadata person object to cff dict for person format."""
66- raise NotImplementedError
66+ ret = {}
67+ person_id = person .orcid or person .to_name_email_string ()
68+ ret ["id" ] = person_id
69+ ret ["name" ] = person .name
70+ ret ["email" ] = person .email
71+ if person .orcid :
72+ ret ["url" ] = person .orcid
73+ if person .contribution_types :
74+ ret ["roles" ] = dict (role = person .contribution_types )
75+ return ret
6776
6877 @staticmethod
6978 def _to_person (person_obj ) -> Person :
7079 """Parse CFF Person to a somesy Person."""
80+ return Person (
81+ name = person_obj ["name" ],
82+ email = person_obj ["email" ],
83+ orcid = person_obj ["orcid" ],
84+ contribution_types = person_obj ["roles" ]["role" ],
85+ )
7186 raise NotImplementedError
0 commit comments