mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Ignore duplicated manifest values
This commit is contained in:
@@ -167,7 +167,7 @@ class BaseManifestParser(object):
|
|||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def str_to_list(value, sep=",", lowercase=False):
|
def str_to_list(value, sep=",", lowercase=False, unique=False):
|
||||||
if isinstance(value, string_types):
|
if isinstance(value, string_types):
|
||||||
value = value.split(sep)
|
value = value.split(sep)
|
||||||
assert isinstance(value, list)
|
assert isinstance(value, list)
|
||||||
@@ -178,6 +178,8 @@ class BaseManifestParser(object):
|
|||||||
continue
|
continue
|
||||||
if lowercase:
|
if lowercase:
|
||||||
item = item.lower()
|
item = item.lower()
|
||||||
|
if unique and item in result:
|
||||||
|
continue
|
||||||
result.append(item)
|
result.append(item)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -323,10 +325,12 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
|||||||
# normalize Union[str, list] fields
|
# normalize Union[str, list] fields
|
||||||
for k in ("keywords", "platforms", "frameworks"):
|
for k in ("keywords", "platforms", "frameworks"):
|
||||||
if k in data:
|
if k in data:
|
||||||
data[k] = self.str_to_list(data[k], sep=",", lowercase=True)
|
data[k] = self.str_to_list(
|
||||||
|
data[k], sep=",", lowercase=True, unique=True
|
||||||
|
)
|
||||||
|
|
||||||
if "headers" in data:
|
if "headers" in data:
|
||||||
data["headers"] = self.str_to_list(data["headers"], sep=",")
|
data["headers"] = self.str_to_list(data["headers"], sep=",", unique=True)
|
||||||
if "authors" in data:
|
if "authors" in data:
|
||||||
data["authors"] = self._parse_authors(data["authors"])
|
data["authors"] = self._parse_authors(data["authors"])
|
||||||
if "platforms" in data:
|
if "platforms" in data:
|
||||||
@@ -370,7 +374,8 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
|||||||
for item in raw:
|
for item in raw:
|
||||||
if item == "espressif":
|
if item == "espressif":
|
||||||
item = "espressif8266"
|
item = "espressif8266"
|
||||||
result.append(item)
|
if item not in result:
|
||||||
|
result.append(item)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -433,7 +438,7 @@ class ModuleJsonManifestParser(BaseManifestParser):
|
|||||||
data["dependencies"] = self._parse_dependencies(data["dependencies"])
|
data["dependencies"] = self._parse_dependencies(data["dependencies"])
|
||||||
if "keywords" in data:
|
if "keywords" in data:
|
||||||
data["keywords"] = self.str_to_list(
|
data["keywords"] = self.str_to_list(
|
||||||
data["keywords"], sep=",", lowercase=True
|
data["keywords"], sep=",", lowercase=True, unique=True
|
||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -485,7 +490,7 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if "includes" in data:
|
if "includes" in data:
|
||||||
data["headers"] = self.str_to_list(data["includes"], ",")
|
data["headers"] = self.str_to_list(data["includes"], sep=",", unique=True)
|
||||||
del data["includes"]
|
del data["includes"]
|
||||||
if "author" in data:
|
if "author" in data:
|
||||||
data["authors"] = self._parse_authors(data)
|
data["authors"] = self._parse_authors(data)
|
||||||
@@ -650,7 +655,7 @@ class PlatformJsonManifestParser(BaseManifestParser):
|
|||||||
def parse(self, contents):
|
def parse(self, contents):
|
||||||
data = json.loads(contents)
|
data = json.loads(contents)
|
||||||
if "keywords" in data:
|
if "keywords" in data:
|
||||||
data["keywords"] = self.str_to_list(data["keywords"], sep=",")
|
data["keywords"] = self.str_to_list(data["keywords"], sep=",", unique=True)
|
||||||
if "frameworks" in data:
|
if "frameworks" in data:
|
||||||
data["frameworks"] = self._parse_frameworks(data["frameworks"])
|
data["frameworks"] = self._parse_frameworks(data["frameworks"])
|
||||||
if "packages" in data:
|
if "packages" in data:
|
||||||
@@ -682,7 +687,7 @@ class PackageJsonManifestParser(BaseManifestParser):
|
|||||||
data = json.loads(contents)
|
data = json.loads(contents)
|
||||||
if "keywords" in data:
|
if "keywords" in data:
|
||||||
data["keywords"] = self.str_to_list(
|
data["keywords"] = self.str_to_list(
|
||||||
data["keywords"], sep=",", lowercase=True
|
data["keywords"], sep=",", lowercase=True, unique=True
|
||||||
)
|
)
|
||||||
data = self._parse_system(data)
|
data = self._parse_system(data)
|
||||||
data = self._parse_homepage(data)
|
data = self._parse_homepage(data)
|
||||||
|
@@ -28,7 +28,7 @@ def test_library_json_parser():
|
|||||||
contents = """
|
contents = """
|
||||||
{
|
{
|
||||||
"name": "TestPackage",
|
"name": "TestPackage",
|
||||||
"keywords": "kw1, KW2, kw3",
|
"keywords": "kw1, KW2, kw3, KW2",
|
||||||
"headers": "include1.h, Include2.hpp",
|
"headers": "include1.h, Include2.hpp",
|
||||||
"platforms": ["atmelavr", "espressif"],
|
"platforms": ["atmelavr", "espressif"],
|
||||||
"repository": {
|
"repository": {
|
||||||
|
Reference in New Issue
Block a user