@@ -79,24 +79,28 @@ def parse_oss_information(self, f_name):
79
79
else :
80
80
comment .append ('direct' )
81
81
82
- tmp_dn_loc = self .dn_url + package_path
82
+ homepage_set = []
83
+ homepage = self .dn_url + package_path
84
+
83
85
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 )
87
89
88
90
license_name = ''
89
- homepage = ''
91
+ dn_loc = ''
92
+
93
+ if oss_version .startswith ('v' ):
94
+ oss_version = oss_version [1 :]
90
95
91
- for dn_loc_i in [ dn_loc , tmp_dn_loc ] :
96
+ for homepage_i in homepage_set :
92
97
try :
93
- res = urllib .request .urlopen (dn_loc_i )
98
+ res = urllib .request .urlopen (homepage_i )
94
99
if res .getcode () == 200 :
95
100
urlopen_success = True
96
- if dn_loc_i == tmp_dn_loc :
101
+ if homepage_i == homepage :
97
102
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.' )
100
104
break
101
105
except Exception :
102
106
continue
@@ -111,7 +115,9 @@ def parse_oss_information(self, f_name):
111
115
112
116
repository_data = bs_obj .find ('div' , {'class' : 'UnitMeta-repo' })
113
117
if repository_data :
114
- homepage = repository_data .find ('a' )['href' ]
118
+ dn_loc = repository_data .find ('a' )['href' ]
119
+ else :
120
+ dn_loc = homepage
115
121
116
122
except Exception as e :
117
123
logging .warning (f"Fail to parse { package_path } in go mod : { e } " )
0 commit comments