mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Parse dev-platform keywords
This commit is contained in:
@ -159,6 +159,21 @@ class BaseManifestParser(object):
|
|||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def str_to_list(value, sep=",", lowercase=True):
|
||||||
|
if isinstance(value, string_types):
|
||||||
|
value = value.split(sep)
|
||||||
|
assert isinstance(value, list)
|
||||||
|
result = []
|
||||||
|
for item in value:
|
||||||
|
item = item.strip()
|
||||||
|
if not item:
|
||||||
|
continue
|
||||||
|
if lowercase:
|
||||||
|
item = item.lower()
|
||||||
|
result.append(item)
|
||||||
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize_author(author):
|
def normalize_author(author):
|
||||||
assert isinstance(author, dict)
|
assert isinstance(author, dict)
|
||||||
@ -296,7 +311,7 @@ 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=",")
|
data[k] = self.str_to_list(data[k], sep=",")
|
||||||
|
|
||||||
if "authors" in data:
|
if "authors" in data:
|
||||||
data["authors"] = self._parse_authors(data["authors"])
|
data["authors"] = self._parse_authors(data["authors"])
|
||||||
@ -309,21 +324,6 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _str_to_list(value, sep=",", lowercase=True):
|
|
||||||
if isinstance(value, string_types):
|
|
||||||
value = value.split(sep)
|
|
||||||
assert isinstance(value, list)
|
|
||||||
result = []
|
|
||||||
for item in value:
|
|
||||||
item = item.strip()
|
|
||||||
if not item:
|
|
||||||
continue
|
|
||||||
if lowercase:
|
|
||||||
item = item.lower()
|
|
||||||
result.append(item)
|
|
||||||
return result
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_renamed_fields(data):
|
def _process_renamed_fields(data):
|
||||||
if "url" in data:
|
if "url" in data:
|
||||||
@ -617,6 +617,8 @@ class PlatformJsonManifestParser(BaseManifestParser):
|
|||||||
|
|
||||||
def parse(self, contents):
|
def parse(self, contents):
|
||||||
data = json.loads(contents)
|
data = json.loads(contents)
|
||||||
|
if "keywords" in data:
|
||||||
|
data["keywords"] = self.str_to_list(data["keywords"], sep=",")
|
||||||
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:
|
||||||
|
@ -544,8 +544,8 @@ def test_platform_json_schema():
|
|||||||
"name": "atmelavr",
|
"name": "atmelavr",
|
||||||
"title": "Atmel AVR",
|
"title": "Atmel AVR",
|
||||||
"description": "Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming.",
|
"description": "Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming.",
|
||||||
"url": "http://www.atmel.com/products/microcontrollers/avr/default.aspx",
|
"keywords": "arduino, atmel, avr",
|
||||||
"homepage": "http://platformio.org/platforms/atmelavr",
|
"homepage": "http://www.atmel.com/products/microcontrollers/avr/default.aspx",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"platformio": "<5"
|
"platformio": "<5"
|
||||||
@ -603,7 +603,8 @@ def test_platform_json_schema():
|
|||||||
"on the industrys most code-efficient architecture for C and "
|
"on the industrys most code-efficient architecture for C and "
|
||||||
"assembly programming."
|
"assembly programming."
|
||||||
),
|
),
|
||||||
"homepage": "http://platformio.org/platforms/atmelavr",
|
"keywords": ["arduino", "atmel", "avr"],
|
||||||
|
"homepage": "http://www.atmel.com/products/microcontrollers/avr/default.aspx",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/platformio/platform-atmelavr.git",
|
"url": "https://github.com/platformio/platform-atmelavr.git",
|
||||||
|
Reference in New Issue
Block a user