mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Ignore maintainer's broken email in library.properties manifest
This commit is contained in:
@ -181,7 +181,7 @@ class BaseManifestParser(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize_author(author):
|
def cleanup_author(author):
|
||||||
assert isinstance(author, dict)
|
assert isinstance(author, dict)
|
||||||
if author.get("email"):
|
if author.get("email"):
|
||||||
author["email"] = re.sub(r"\s+[aA][tT]\s+", "@", author["email"])
|
author["email"] = re.sub(r"\s+[aA][tT]\s+", "@", author["email"])
|
||||||
@ -357,7 +357,7 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
|||||||
# normalize Union[dict, list] fields
|
# normalize Union[dict, list] fields
|
||||||
if not isinstance(raw, list):
|
if not isinstance(raw, list):
|
||||||
raw = [raw]
|
raw = [raw]
|
||||||
return [self.normalize_author(author) for author in raw]
|
return [self.cleanup_author(author) for author in raw]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_platforms(raw):
|
def _parse_platforms(raw):
|
||||||
@ -430,7 +430,7 @@ class ModuleJsonManifestParser(BaseManifestParser):
|
|||||||
name, email = self.parse_author_name_and_email(author)
|
name, email = self.parse_author_name_and_email(author)
|
||||||
if not name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
result.append(self.normalize_author(dict(name=name, email=email)))
|
result.append(self.cleanup_author(dict(name=name, email=email)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -471,7 +471,9 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
|
|||||||
)
|
)
|
||||||
if "author" in data:
|
if "author" in data:
|
||||||
data["authors"] = self._parse_authors(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:
|
if "depends" in data:
|
||||||
data["dependencies"] = self._parse_dependencies(data["depends"])
|
data["dependencies"] = self._parse_dependencies(data["depends"])
|
||||||
return data
|
return data
|
||||||
@ -544,7 +546,7 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
|
|||||||
name, email = self.parse_author_name_and_email(author)
|
name, email = self.parse_author_name_and_email(author)
|
||||||
if not name:
|
if not name:
|
||||||
continue
|
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(","):
|
for author in properties.get("maintainer", "").split(","):
|
||||||
name, email = self.parse_author_name_and_email(author)
|
name, email = self.parse_author_name_and_email(author)
|
||||||
if not name:
|
if not name:
|
||||||
@ -555,11 +557,11 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
|
|||||||
continue
|
continue
|
||||||
found = True
|
found = True
|
||||||
item["maintainer"] = True
|
item["maintainer"] = True
|
||||||
if not item.get("email") and email:
|
if not item.get("email") and email and "@" in email:
|
||||||
item["email"] = email
|
item["email"] = email
|
||||||
if not found:
|
if not found:
|
||||||
authors.append(
|
authors.append(
|
||||||
self.normalize_author(dict(name=name, email=email, maintainer=True))
|
self.cleanup_author(dict(name=name, email=email, maintainer=True))
|
||||||
)
|
)
|
||||||
return authors
|
return authors
|
||||||
|
|
||||||
|
@ -198,7 +198,8 @@ def test_library_properties_parser():
|
|||||||
contents = """
|
contents = """
|
||||||
name=TestPackage
|
name=TestPackage
|
||||||
version=1.2.3
|
version=1.2.3
|
||||||
author=SomeAuthor <info AT author.com>, Another Author (nickname) <www.example.com>
|
author=SomeAuthor <info AT author.com>, Maintainer Author (nickname) <www.example.com>
|
||||||
|
maintainer=Maintainer Author (nickname) <www.example.com>
|
||||||
sentence=This is Arduino library
|
sentence=This is Arduino library
|
||||||
customField=Custom Value
|
customField=Custom Value
|
||||||
depends=First Library (=2.0.0), Second Library (>=1.2.0), Third
|
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"]
|
"exclude": ["extras", "docs", "tests", "test", "*.doxyfile", "*.pdf"]
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{"email": "info@author.com", "name": "SomeAuthor"},
|
{"name": "SomeAuthor", "email": "info@author.com"},
|
||||||
{"name": "Another Author"},
|
{"name": "Maintainer Author", "maintainer": True},
|
||||||
],
|
],
|
||||||
"keywords": ["uncategorized"],
|
"keywords": ["uncategorized"],
|
||||||
"customField": "Custom Value",
|
"customField": "Custom Value",
|
||||||
|
Reference in New Issue
Block a user