Improve parsing "author" field of library.properties manfiest

This commit is contained in:
Ivan Kravets
2020-07-08 20:21:10 +03:00
parent 40d6847c96
commit 42fd284560
2 changed files with 12 additions and 6 deletions

View File

@ -198,10 +198,13 @@ class BaseManifestParser(object):
return (None, None)
name = raw
email = None
for ldel, rdel in [("<", ">"), ("(", ")")]:
if ldel in raw and rdel in raw:
name = raw[: raw.index(ldel)]
email = raw[raw.index(ldel) + 1 : raw.index(rdel)]
ldel = "<"
rdel = ">"
if ldel in raw and rdel in raw:
name = raw[: raw.index(ldel)]
email = raw[raw.index(ldel) + 1 : raw.index(rdel)]
if "(" in name:
name = name.split("(")[0]
return (name.strip(), email.strip() if email else None)
@staticmethod

View File

@ -198,7 +198,7 @@ def test_library_properties_parser():
contents = """
name=TestPackage
version=1.2.3
author=SomeAuthor <info AT author.com>
author=SomeAuthor <info AT author.com>, Another Author (nickname) <www.example.com>
sentence=This is Arduino library
customField=Custom Value
depends=First Library (=2.0.0), Second Library (>=1.2.0), Third
@ -218,7 +218,10 @@ ignore_empty_field=
"export": {
"exclude": ["extras", "docs", "tests", "test", "*.doxyfile", "*.pdf"]
},
"authors": [{"email": "info@author.com", "name": "SomeAuthor"}],
"authors": [
{"email": "info@author.com", "name": "SomeAuthor"},
{"name": "Another Author"},
],
"keywords": ["uncategorized"],
"customField": "Custom Value",
"depends": "First Library (=2.0.0), Second Library (>=1.2.0), Third",