Parse dev-platform keywords
This commit is contained in:
@@ -159,6 +159,21 @@ class BaseManifestParser(object):
|
||||
def as_dict(self):
|
||||
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
|
||||
def normalize_author(author):
|
||||
assert isinstance(author, dict)
|
||||
@@ -296,7 +311,7 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
||||
# normalize Union[str, list] fields
|
||||
for k in ("keywords", "platforms", "frameworks"):
|
||||
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:
|
||||
data["authors"] = self._parse_authors(data["authors"])
|
||||
@@ -309,21 +324,6 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
||||
|
||||
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
|
||||
def _process_renamed_fields(data):
|
||||
if "url" in data:
|
||||
@@ -617,6 +617,8 @@ class PlatformJsonManifestParser(BaseManifestParser):
|
||||
|
||||
def parse(self, contents):
|
||||
data = json.loads(contents)
|
||||
if "keywords" in data:
|
||||
data["keywords"] = self.str_to_list(data["keywords"], sep=",")
|
||||
if "frameworks" in data:
|
||||
data["frameworks"] = self._parse_frameworks(data["frameworks"])
|
||||
if "packages" in data:
|
||||
|
||||
Reference in New Issue
Block a user