diff --git a/platformio/package/manifest/parser.py b/platformio/package/manifest/parser.py index 28743e54..8ba94344 100644 --- a/platformio/package/manifest/parser.py +++ b/platformio/package/manifest/parser.py @@ -181,7 +181,7 @@ class BaseManifestParser(object): return result @staticmethod - def normalize_author(author): + def cleanup_author(author): assert isinstance(author, dict) if author.get("email"): author["email"] = re.sub(r"\s+[aA][tT]\s+", "@", author["email"]) @@ -357,7 +357,7 @@ class LibraryJsonManifestParser(BaseManifestParser): # normalize Union[dict, list] fields if not isinstance(raw, list): raw = [raw] - return [self.normalize_author(author) for author in raw] + return [self.cleanup_author(author) for author in raw] @staticmethod def _parse_platforms(raw): @@ -430,7 +430,7 @@ class ModuleJsonManifestParser(BaseManifestParser): name, email = self.parse_author_name_and_email(author) if not name: continue - result.append(self.normalize_author(dict(name=name, email=email))) + result.append(self.cleanup_author(dict(name=name, email=email))) return result @staticmethod @@ -471,7 +471,9 @@ class LibraryPropertiesManifestParser(BaseManifestParser): ) if "author" in data: data["authors"] = self._parse_authors(data) - del data["author"] + for key in ("author", "maintainer"): + if key in data: + del data[key] if "depends" in data: data["dependencies"] = self._parse_dependencies(data["depends"]) return data @@ -544,7 +546,7 @@ class LibraryPropertiesManifestParser(BaseManifestParser): name, email = self.parse_author_name_and_email(author) if not name: continue - authors.append(self.normalize_author(dict(name=name, email=email))) + authors.append(self.cleanup_author(dict(name=name, email=email))) for author in properties.get("maintainer", "").split(","): name, email = self.parse_author_name_and_email(author) if not name: @@ -555,11 +557,11 @@ class LibraryPropertiesManifestParser(BaseManifestParser): continue found = True item["maintainer"] = True - if not item.get("email") and email: + if not item.get("email") and email and "@" in email: item["email"] = email if not found: authors.append( - self.normalize_author(dict(name=name, email=email, maintainer=True)) + self.cleanup_author(dict(name=name, email=email, maintainer=True)) ) return authors diff --git a/tests/package/test_manifest.py b/tests/package/test_manifest.py index c2436328..188c5d8e 100644 --- a/tests/package/test_manifest.py +++ b/tests/package/test_manifest.py @@ -198,7 +198,8 @@ def test_library_properties_parser(): contents = """ name=TestPackage version=1.2.3 -author=SomeAuthor , Another Author (nickname) +author=SomeAuthor , Maintainer Author (nickname) +maintainer=Maintainer Author (nickname) sentence=This is Arduino library customField=Custom Value depends=First Library (=2.0.0), Second Library (>=1.2.0), Third @@ -219,8 +220,8 @@ ignore_empty_field= "exclude": ["extras", "docs", "tests", "test", "*.doxyfile", "*.pdf"] }, "authors": [ - {"email": "info@author.com", "name": "SomeAuthor"}, - {"name": "Another Author"}, + {"name": "SomeAuthor", "email": "info@author.com"}, + {"name": "Maintainer Author", "maintainer": True}, ], "keywords": ["uncategorized"], "customField": "Custom Value",