Skip to content

Commit 12e0a37

Browse files
committed
Extend support across other handlers
Signed-off-by: Varsha U N <[email protected]>
1 parent de9250a commit 12e0a37

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/packagedcode/pypi.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from packagedcode.utils import yield_dependencies_from_package_data
4545
from packagedcode.utils import yield_dependencies_from_package_resource
4646
from packagedcode.utils import get_base_purl
47+
from packagedcode.utils import is_private_package
4748

4849
try:
4950
from zipfile import Path as ZipPath
@@ -511,9 +512,7 @@ def parse(cls, location, package_only=False):
511512
description = project_data.get('description') or ''
512513
description = description.strip()
513514

514-
classifiers = project_data.get('classifiers', [])
515-
is_private = any('Private ::' in classifier for classifier in classifiers)
516-
515+
is_private = is_private_package(project_data.get('classifiers', []))
517516
urls, extra_data = get_urls(metainfo=project_data, name=name, version=version)
518517

519518
extracted_license_statement, license_file = get_declared_license(project_data)
@@ -552,7 +551,6 @@ def parse(cls, location, package_only=False):
552551
)
553552
yield models.PackageData.from_data(package_data, package_only)
554553

555-
556554
def is_poetry_pyproject_toml(location):
557555
with open(location, 'r') as file:
558556
data = file.read()
@@ -741,6 +739,8 @@ def parse(cls, location, package_only=False):
741739
)
742740
dependencies.append(dependency.to_dict())
743741

742+
is_private = is_private_package(poetry_data.get('classifiers', []))
743+
744744
package_data = dict(
745745
datasource_id=cls.datasource_id,
746746
type=cls.default_package_type,
@@ -1019,6 +1019,9 @@ def parse_metadata(location, datasource_id, package_type, package_only=False):
10191019
if license_file:
10201020
extra_data['license_file'] = license_file
10211021

1022+
classifiers = get_attribute(meta, 'Classifier', multiple=True)
1023+
is_private = is_private_package(classifiers)
1024+
10221025
# FIXME: We are getting dependencies from other sibling files, this is duplicated
10231026
# data at the package_data level, is this necessary? We also have the entire dependency
10241027
# relationships here at requires.txt present in ``.egg-info`` should we store these
@@ -1039,6 +1042,7 @@ def parse_metadata(location, datasource_id, package_type, package_only=False):
10391042
dependencies=dependencies,
10401043
file_references=file_references,
10411044
extra_data=extra_data,
1045+
is_private=is_private,
10421046
**urls,
10431047
)
10441048
return models.PackageData.from_data(package_data, package_only)
@@ -1214,6 +1218,8 @@ def parse(cls, location, package_only=False):
12141218
if license_file:
12151219
extra_data['license_file'] = license_file
12161220

1221+
is_private = is_private_package(setup_args.get('classifiers', []))
1222+
12171223
package_data = dict(
12181224
datasource_id=cls.datasource_id,
12191225
type=cls.default_package_type,
@@ -1343,6 +1349,9 @@ def parse(cls, location, package_only=False):
13431349
extracted_license_statement = ''
13441350
extracted_license_statement += f" license_files: {license_file_references}"
13451351

1352+
classifiers = parser.get('metadata', 'classifiers', fallback='').splitlines()
1353+
is_private = is_private_package(classifiers)
1354+
13461355
package_data = dict(
13471356
datasource_id=cls.datasource_id,
13481357
type=cls.default_package_type,
@@ -2286,7 +2295,7 @@ def get_pypi_urls(name, version, **kwargs):
22862295
)
22872296

22882297

2289-
def get_urls(metainfo, name, version,is_private, poetry=False):
2298+
def get_urls(metainfo, name, version, is_private=False, poetry=False):
22902299
"""
22912300
Return a mapping of standard URLs and a mapping of extra-data URls for URLs
22922301
of this package:

src/packagedcode/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,7 @@ def is_simple_path(path):
304304

305305
def is_simple_path_pattern(path):
306306
return path.endswith('*') and path.count('*') == 1
307+
308+
309+
def is_private_package(classifiers):
310+
return any('Private ::' in classifier for classifier in classifiers if classifier)

0 commit comments

Comments
 (0)