Skip to content

Commit 3ebaf2d

Browse files
authored
Merge pull request #2520 from nexB/173-scio-system-packages
Correct corner cases for empty rpm locations
2 parents bb04420 + ae2897e commit 3ebaf2d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/packagedcode/rpm_installed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def parse_rpm_xmlish(location, detect_licenses=False):
4040
Yield RpmPackage(s) from a RPM XML'ish file at `location`. This is a file
4141
created with rpm and the xml query option.
4242
"""
43-
if not os.path.exists(location):
43+
if not location or not os.path.exists(location):
4444
return
4545

4646
# there are smetimes weird encodings. We avoid issues there

tests/packagedcode/test_rpm_installed.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def test_parse_rpm_xmlish(self):
5757
result = json.loads(json.dumps(result))
5858
check_result_equals_expected_json(result, expected, regen=False)
5959

60+
def test_parse_rpm_xmlish_does_not_with_empty_or_missing_location(self):
61+
rpm_installed.parse_rpm_xmlish(None)
62+
rpm_installed.parse_rpm_xmlish('')
63+
rpm_installed.parse_rpm_xmlish('/foo/bar/does-not-exists')
64+
6065
def test_parse_rpm_xmlish_can_detect_license(self):
6166
test_installed = self.get_test_loc('rpm_installed/xmlish/centos-5-rpms.xmlish')
6267
expected = self.get_test_loc('rpm_installed/xmlish/centos-5-rpms.xmlish-with-license-expected.json')

0 commit comments

Comments
 (0)