Skip to content

Commit 374df03

Browse files
author
Li
committed
#395 Add the vendor support
1 parent 287bbc2 commit 374df03

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

src/packagedcode/phpcomposer.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def parse(location):
105105
base_dir = fileutils.parent_directory(location)
106106
package.location = base_dir
107107
package.metafile_locations = [location]
108-
package.version = data.get('version')
108+
109109
for source, target in plain_fields.items():
110110
value = data.get(source)
111111
if value:
@@ -122,6 +122,7 @@ def parse(location):
122122
value = value.strip()
123123
if value:
124124
func(value, package)
125+
vendor_mapper(package) # Parse vendor from name value
125126
return package
126127

127128

@@ -189,6 +190,19 @@ def support_mapper(support, package):
189190
return package
190191

191192

193+
def vendor_mapper(package):
194+
"""
195+
Vender is part of name element.
196+
https://getcomposer.org/doc/04-schema.md#name
197+
"""
198+
name = package.name
199+
if name and '/' in name:
200+
vendors = name.split('/')
201+
if vendors[0]:
202+
package.vendors = [models.Party(name=vendors[0])]
203+
return package
204+
205+
192206
def repository_mapper(repos, package):
193207
"""
194208
https://getcomposer.org/doc/04-schema.md#repositories

tests/packagedcode/data/phpcomposer/a-timer/composer.json.expected

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
"owners": [],
2121
"packagers": [],
2222
"distributors": [],
23-
"vendors": [],
23+
"vendors": [
24+
{
25+
"type": null,
26+
"name": "jandreasn",
27+
"email": null,
28+
"url": null
29+
}
30+
],
2431
"keywords": [
2532
"timer",
2633
"timing",

tests/packagedcode/data/phpcomposer/framework/composer.json.expected

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
"owners": [],
2121
"packagers": [],
2222
"distributors": [],
23-
"vendors": [],
23+
"vendors": [
24+
{
25+
"type": null,
26+
"name": "narrowspark",
27+
"email": null,
28+
"url": null
29+
}
30+
],
2431
"keywords": [
2532
"framework",
2633
"narrowspark",

tests/packagedcode/data/phpcomposer/slim/composer.json.expected

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@
3838
"owners": [],
3939
"packagers": [],
4040
"distributors": [],
41-
"vendors": [],
41+
"vendors": [
42+
{
43+
"type": null,
44+
"name": "slim",
45+
"email": null,
46+
"url": null
47+
}
48+
],
4249
"keywords": [
4350
"framework",
4451
"micro",

0 commit comments

Comments
 (0)