Skip to content

Commit d8ed0f5

Browse files
authored
Merge pull request #89 from fosslight/develop
Change the output for Go
2 parents 2739616 + 108cecc commit d8ed0f5

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ lxml
44
virtualenv
55
pyyaml
66
lastversion
7-
fosslight_util>=1.3.12
7+
fosslight_util>=1.4.0
88
PyGithub
99
requirements-parser

src/fosslight_dependency/package_manager/Go.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,28 @@ def parse_oss_information(self, f_name):
7979
else:
8080
comment.append('direct')
8181

82-
tmp_dn_loc = self.dn_url + package_path
82+
homepage_set = []
83+
homepage = self.dn_url + package_path
84+
8385
if oss_version:
84-
dn_loc = f"{tmp_dn_loc}@{oss_version}"
85-
else:
86-
dn_loc = tmp_dn_loc
86+
tmp_homepage = f"{homepage}@{oss_version}"
87+
homepage_set.append(tmp_homepage)
88+
homepage_set.append(homepage)
8789

8890
license_name = ''
89-
homepage = ''
91+
dn_loc = ''
92+
93+
if oss_version.startswith('v'):
94+
oss_version = oss_version[1:]
9095

91-
for dn_loc_i in [dn_loc, tmp_dn_loc]:
96+
for homepage_i in homepage_set:
9297
try:
93-
res = urllib.request.urlopen(dn_loc_i)
98+
res = urllib.request.urlopen(homepage_i)
9499
if res.getcode() == 200:
95100
urlopen_success = True
96-
if dn_loc_i == tmp_dn_loc:
101+
if homepage_i == homepage:
97102
if oss_version:
98-
comment.append(f'Cannot connect {dn_loc}, get info from the latest version.')
99-
dn_loc = tmp_dn_loc
103+
comment.append(f'Cannot connect {tmp_homepage}, get info from the latest version.')
100104
break
101105
except Exception:
102106
continue
@@ -111,7 +115,9 @@ def parse_oss_information(self, f_name):
111115

112116
repository_data = bs_obj.find('div', {'class': 'UnitMeta-repo'})
113117
if repository_data:
114-
homepage = repository_data.find('a')['href']
118+
dn_loc = repository_data.find('a')['href']
119+
else:
120+
dn_loc = homepage
115121

116122
except Exception as e:
117123
logging.warning(f"Fail to parse {package_path} in go mod : {e}")

0 commit comments

Comments
 (0)