Skip to content

Commit

Permalink
Refactor and address feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Jul 12, 2023
1 parent f117a76 commit 0165bdf
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 15 deletions.
22 changes: 17 additions & 5 deletions src/packagedcode/jar_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def dget(s):
package['homepage_url'] = dget('Implementation-URL') or dget('Implementation-Url')

# Bundle-DocURL: http://logging.apache.org/log4j/1.2
#package['documentation_url'] = dget('Bundle-DocURL')
doc_url = dget('Bundle-DocURL')

# vendor/owner/contact
#########################
Expand Down Expand Up @@ -339,7 +339,15 @@ def dget(s):
# Deps:
# Require-Bundle

#package['notes'] = dget('Comment')
comment = dget('Comment')

if comment or doc_url:
package["extra_data"] = {}
if comment:
package["extra_data"]['notes'] = comment
if doc_url:
package["extra_data"]['documentation_url'] = doc_url

return package


Expand Down Expand Up @@ -378,16 +386,20 @@ def parse_scm_connection(scm_connection):


def get_datasource_id(package_type):
"""
Get the corresponding `datasource_id` for the given
`package_type`. This is a seperate function to avoid
cyclic imports.
"""
from packagedcode.maven import JavaJarManifestHandler
from packagedcode.maven import JavaOSGiManifestHandler

if package_type == 'maven':
return JavaJarManifestHandler.datasource_id
elif package_type == 'jar':
if package_type in ['maven', 'jar']:
return JavaJarManifestHandler.datasource_id
elif package_type == 'osgi':
return JavaOSGiManifestHandler.datasource_id


def is_id(s):
"""
Return True if `s` is some kind of id.
Expand Down
6 changes: 3 additions & 3 deletions src/packagedcode/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,11 +1308,11 @@ def get_license_detections_for_extracted_license_statement(

for license_entry in new_extracted_license:
license_entry.pop("distribution")
if not license_entry.get("name", None):
if not license_entry.get("name"):
license_entry.pop("name")
if not license_entry.get("url", None):
if not license_entry.get("url"):
license_entry.pop("url")
if not license_entry.get("comments", None):
if not license_entry.get("comments"):
license_entry.pop("comments")

extracted_license_statement = saneyaml.dump(new_extracted_license)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@
"notice_text": null,
"source_packages": [],
"file_references": [],
"extra_data": {},
"extra_data": {
"documentation_url": "http://johnzon.apache.org/"
},
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://www.hibernate.org/orm/5.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://www.oracle.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://logging.apache.org/log4j/1.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://www.oracle.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://fusesource.com/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
}
],
"vcs_url": null,
"code_view_url": null
"code_view_url": null,
"extra_data": {
"documentation_url": "http://jodd.org"
}
}

0 comments on commit 0165bdf

Please sign in to comment.