Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/fosslight_util/_get_downloadable_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ def get_download_location_for_pypi(link):
content = urlopen(pypi_url).read().decode('utf8')
bs_obj = BeautifulSoup(content, 'html.parser')

tr_list = bs_obj.find('div', {'id': 'files'}).findAll('tr')
for i in tr_list:
td = i.findAll('td')
for td_i in td:
str_i = str(td_i).replace('\n', ' ')
if re.findall(r'<span class="table__mobile-label">File type</span>[\s]*(Source)[\s]*</td>', str_i):
new_link = i.find('a').attrs['href']
ret = True
break
card_file_list = bs_obj.findAll('div', {'class': 'card file__card'})

for card_file in card_file_list:
file_code = card_file.find('code').text
if file_code == "source":
new_link = card_file.find('a').attrs['href']
ret = True
break
except Exception as error:
ret = False
logger.warning('Cannot find the link for pypi (url:'+link+') '+str(error))
Expand Down
5 changes: 4 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


def main():
cli_download_and_extract("https://github.com/LGE-OSS/example", "test_result/download", "test_result/download_log")
cli_download_and_extract("https://github.com/LGE-OSS/example",
"test_result/download/example", "test_result/download_log/example")
cli_download_and_extract("https://pypi.org/project/filelock/3.4.1",
"test_result/download/filelock", "test_result/download_log/filelock")


if __name__ == '__main__':
Expand Down