Skip to content

Commit 3b14642

Browse files
authored
Merge pull request #118 from Materials-Data-Science-and-Informatics/fix/author_list
Fix/author list
2 parents 1de5871 + 28bea32 commit 3b14642

15 files changed

Lines changed: 212 additions & 94 deletions

File tree

.somesy.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "somesy"
3-
version = "0.7.2"
3+
version = "0.7.3"
44
description = "A CLI tool for synchronizing software project metadata."
55
keywords = ["metadata", "FAIR"]
66
license = "MIT"
@@ -12,7 +12,7 @@ documentation = "https://materials-data-science-and-informatics.github.io/somesy
1212
family-names = "Soylu"
1313
given-names = "Mustafa"
1414
email = "m.soylu@fz-juelich.de"
15-
orcid = "https://orcid.org/0000-0003-2637-0432"
15+
orcid = "0000-0003-2637-0432"
1616

1717
contribution = "Main developer, maintainer and tester."
1818
contribution_begin = "2023-03-01"
@@ -25,7 +25,7 @@ maintainer = true
2525
family-names = "Pirogov"
2626
given-names = "Anton"
2727
email = "a.pirogov@fz-juelich.de"
28-
orcid = "https://orcid.org/0000-0002-5077-7497"
28+
orcid = "0000-0002-5077-7497"
2929

3030
contribution = "Concepts, tool development and enhancement, documentation."
3131
contribution_begin = "2023-03-01"
@@ -38,7 +38,7 @@ author = true
3838
family-names = "Bröder"
3939
given-names = "Jens"
4040
email = "j.broeder@fz-juelich.de"
41-
orcid = "https://orcid.org/0000-0001-7939-226X"
41+
orcid = "0000-0001-7939-226X"
4242

4343
contribution = "Discussions and suggestions concerning metadata standards and usability."
4444
contribution_begin = "2023-03-01"
@@ -49,7 +49,7 @@ contribution_types = ["ideas"]
4949
family-names = "Hofmann"
5050
given-names = "Volker"
5151
email = "v.hofmann@fz-juelich.de"
52-
orcid = "https://orcid.org/0000-0002-5149-603X"
52+
orcid = "0000-0002-5149-603X"
5353

5454
contribution = "Discussions and suggestions concerning tool scope and usability."
5555
contribution_begin = "2023-06-01"
@@ -62,7 +62,7 @@ publication_author = true
6262
family-names = "Sandfeld"
6363
given-names = "Stefan"
6464
email = "s.sandfeld@fz-juelich.de"
65-
orcid = "https://orcid.org/0000-0001-9560-4728"
65+
orcid = "0000-0001-9560-4728"
6666

6767
contribution_types = ["fundingFinding"]
6868

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Here we provide notes that summarize the most important changes in each released
44

55
Please consult the changelog to inform yourself about breaking changes and security issues.
66

7+
## [v0.7.3](https://github.com/Materials-Data-Science-and-Informatics/somesy/tree/v0.7.3) <small>(2025-03-14)</small> { id="0.7.3" }
8+
9+
- accept orcid id as string without url
10+
- support multiline description in somesy input and outputs that enables multiline strings
11+
- dont save same person in available output formats
12+
- better toml inline table formatting
13+
- support only orcid id string (without the url)
14+
715
## [v0.7.2](https://github.com/Materials-Data-Science-and-Informatics/somesy/tree/v0.7.2) <small>(2025-03-10)</small> { id="0.7.2" }
816

917
- fix CITATION.CFF formatting

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type: software
33
message: If you use this software, please cite it using this metadata.
44

55
title: somesy
6-
version: 0.7.2
6+
version: 0.7.3
77
abstract: A CLI tool for synchronizing software project metadata.
88
url: https://materials-data-science-and-informatics.github.io/somesy
99
repository-code: https://github.com/Materials-Data-Science-and-Informatics/somesy

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"name": "somesy",
2929
"description": "A CLI tool for synchronizing software project metadata.",
30-
"version": "0.7.2",
30+
"version": "0.7.3",
3131
"keywords": [
3232
"metadata",
3333
"FAIR"

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "somesy"
3-
version = "0.7.2"
3+
version = "0.7.3"
44
description = "A CLI tool for synchronizing software project metadata."
55
readme = "README.md"
66
keywords = [
@@ -33,15 +33,15 @@ dependencies = [
3333
]
3434

3535
authors = [
36-
{name = "Mustafa Soylu",email = "m.soylu@fz-juelich.de"},
37-
{name = "Anton Pirogov",email = "a.pirogov@fz-juelich.de"},
36+
{name = "Mustafa Soylu", email = "m.soylu@fz-juelich.de"},
37+
{name = "Anton Pirogov", email = "a.pirogov@fz-juelich.de"},
3838
]
3939
maintainers = [
40-
{name = "Mustafa Soylu",email = "m.soylu@fz-juelich.de"},
40+
{name = "Mustafa Soylu", email = "m.soylu@fz-juelich.de"},
4141
]
4242

43-
44-
license = {text = "MIT"}
43+
[project.license]
44+
text = "MIT"
4545

4646
[project.urls]
4747
homepage = "https://materials-data-science-and-informatics.github.io/somesy"

src/somesy/cff/writer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from cffconvert.cli.create_citation import create_citation
88
from ruamel.yaml import YAML
9+
from ruamel.yaml.scalarstring import LiteralScalarString
910

1011
from somesy.core.models import Entity, Person, ProjectMetadata
1112
from somesy.core.writer import FieldKeyMapping, IgnoreKey, ProjectMetadataWriter
@@ -71,6 +72,14 @@ def _validate(self) -> None:
7172
def save(self, path: Optional[Path] = None) -> None:
7273
"""Save the CFF object to a file."""
7374
path = path or self.path
75+
76+
# if description have new line characters, it should be saved as multiline string
77+
if "abstract" in self._data:
78+
if "\n" in self._data["abstract"]:
79+
self._data["abstract"] = LiteralScalarString(self._data["abstract"])
80+
else:
81+
self._data["abstract"] = str(self.description)
82+
7483
self._yaml.dump(self._data, path)
7584

7685
def _sync_authors(self, metadata: ProjectMetadata) -> None:

src/somesy/core/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,17 @@ class Person(ContributorBaseModel):
560560

561561
# helper methods
562562

563+
@field_validator("orcid", mode="before")
564+
@classmethod
565+
def orcid_from_string(cls, orcid: str) -> Optional[HttpUrlStr]:
566+
"""Convert orcid id string to HttpUrlStr."""
567+
# orcid regex without https://orcid.org/ prefix
568+
orcid_regex = r"^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]$"
569+
if orcid is not None and isinstance(orcid, str):
570+
if re.match(orcid_regex, orcid):
571+
return f"https://orcid.org/{orcid}"
572+
return orcid
573+
563574
@property
564575
def full_name(self) -> str:
565576
"""Return the full name of the person."""

src/somesy/core/writer.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,27 @@ def _sync_person_list(
251251
252252
"""
253253
old_people: List[Union[Person, Entity]] = self._parse_people(old)
254-
if old_people is None or len(old_people) == 0:
255-
return new
256-
if new is None or len(new) == 0:
257-
return old_people
258-
return self._merge_person_metadata(old_people, new)
254+
255+
# check if people are unique
256+
def filter_unique(
257+
people: List[Union[Person, Entity]],
258+
) -> List[Union[Person, Entity]]:
259+
"""Filter out duplicate people from a list."""
260+
if people is None or len(people) == 0:
261+
return []
262+
263+
unique_people: List[Union[Person, Entity]] = []
264+
# use same_person method to check if people are unique
265+
for person in people:
266+
if not any(person.same_person(p) for p in unique_people):
267+
unique_people.append(person)
268+
269+
return unique_people
270+
271+
old_people_unique = filter_unique(old_people)
272+
new_people_unique = filter_unique(new)
273+
274+
return self._merge_person_metadata(old_people_unique, new_people_unique)
259275

260276
def _sync_authors(self, metadata: ProjectMetadata) -> None:
261277
"""Sync output file authors with authors from metadata.

src/somesy/fortran/writer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@ def _validate(self) -> None:
9191
def save(self, path: Optional[Path] = None) -> None:
9292
"""Save the fpm file."""
9393
path = path or self.path
94+
if "description" in self._data:
95+
if "\n" in self._data["description"]:
96+
self._data["description"] = tomlkit.string(
97+
self._data["description"], multiline=True
98+
)
99+
100+
# Handle arrays with proper formatting
101+
for key, value in self._data.items():
102+
if isinstance(value, list):
103+
array = tomlkit.array()
104+
array.extend(value)
105+
array.multiline(True)
106+
# Ensure whitespace after commas in inline tables
107+
for item in array:
108+
if isinstance(item, tomlkit.items.InlineTable):
109+
# Rebuild the inline table with desired formatting
110+
formatted_item = tomlkit.inline_table()
111+
for k, v in item.value.items():
112+
formatted_item[k] = v
113+
formatted_item.trivia.trail = " " # Add space after each comma
114+
array[array.index(item)] = formatted_item
115+
self._data[key] = array
116+
else:
117+
self._data[key] = value
118+
94119
with open(path, "w") as f:
95120
tomlkit.dump(self._data, f)
96121

src/somesy/julia/writer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ def _validate(self) -> None:
5555
def save(self, path: Optional[Path] = None) -> None:
5656
"""Save the julia file."""
5757
path = path or self.path
58+
if "description" in self._data:
59+
if "\n" in self._data["description"]:
60+
self._data["description"] = tomlkit.string(
61+
self._data["description"], multiline=True
62+
)
63+
64+
# Handle arrays with proper formatting
65+
for key, value in self._data.items():
66+
if isinstance(value, list):
67+
array = tomlkit.array()
68+
array.extend(value)
69+
array.multiline(True)
70+
# Ensure whitespace after commas in inline tables
71+
for item in array:
72+
if isinstance(item, tomlkit.items.InlineTable):
73+
# Rebuild the inline table with desired formatting
74+
formatted_item = tomlkit.inline_table()
75+
for k, v in item.value.items():
76+
formatted_item[k] = v
77+
formatted_item.trivia.trail = " " # Add space after each comma
78+
array[array.index(item)] = formatted_item
79+
self._data[key] = array
80+
else:
81+
self._data[key] = value
82+
5883
with open(path, "w") as f:
5984
tomlkit.dump(self._data, f)
6085

0 commit comments

Comments
 (0)