Flagged by PyCharm.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
Flagged by PyCharm.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | contrib/packaging/hgpackaging/downloads.py (5 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
054a1fb3f0b7 | db37f04b2c9d | Matt Harbison | Apr 18 2022, 4:18 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 |
# downloads.py - Code for downloading dependencies. | # downloads.py - Code for downloading dependencies. | ||||
# | # | ||||
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
# no-check-code because Python 3 native. | # no-check-code because Python 3 native. | ||||
import gzip | import gzip | ||||
import hashlib | import hashlib | ||||
import pathlib | import pathlib | ||||
import typing | |||||
import urllib.request | import urllib.request | ||||
DOWNLOADS = { | DOWNLOADS = { | ||||
'gettext': { | 'gettext': { | ||||
'url': 'https://versaweb.dl.sourceforge.net/project/gnuwin32/gettext/0.14.4/gettext-0.14.4-bin.zip', | 'url': 'https://versaweb.dl.sourceforge.net/project/gnuwin32/gettext/0.14.4/gettext-0.14.4-bin.zip', | ||||
'size': 1606131, | 'size': 1606131, | ||||
'sha256': '60b9ef26bc5cceef036f0424e542106cf158352b2677f43a01affd6d82a1d641', | 'sha256': '60b9ef26bc5cceef036f0424e542106cf158352b2677f43a01affd6d82a1d641', | ||||
tmp.unlink() | tmp.unlink() | ||||
raise | raise | ||||
tmp.rename(path) | tmp.rename(path) | ||||
print('successfully downloaded %s' % url) | print('successfully downloaded %s' % url) | ||||
def download_entry( | def download_entry( | ||||
name: dict, dest_path: pathlib.Path, local_name=None | name: str, dest_path: pathlib.Path, local_name=None | ||||
) -> pathlib.Path: | ) -> typing.Tuple[pathlib.Path, typing.Dict[str, typing.Union[str, int]]]: | ||||
entry = DOWNLOADS[name] | entry = DOWNLOADS[name] | ||||
url = entry['url'] | url = entry['url'] | ||||
local_name = local_name or url[url.rindex('/') + 1 :] | local_name = local_name or url[url.rindex('/') + 1 :] | ||||
local_path = dest_path / local_name | local_path = dest_path / local_name | ||||
download_to_path(url, local_path, entry['size'], entry['sha256']) | download_to_path(url, local_path, entry['size'], entry['sha256']) | ||||
return local_path, entry | return local_path, entry |