From ef3cc13375fc5f3d9450e500f1a9b5493eefdf82 Mon Sep 17 00:00:00 2001 From: Leonardo Taccari Date: Sun, 3 Dec 2023 12:47:35 +0100 Subject: [PATCH 1/3] Extend checks for more Python-s Add a matrix in order to check at least: - oldest Python version - default Python version on pkgsrc-current - newest Python version Set `fail-fast` to `false` (by default it is `true`) in order to run all matrix jobs to see all Python versions that fail instead of pointing out only the first (and non-deterministic) one that fails. Related to #49 and #71. --- .github/workflows/python.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 25a6d8a..9b26c15 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -12,13 +12,17 @@ jobs: build: name: Check and test transferwee runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: ['3.8', '3.10', '3.12'] steps: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python ${{ matrix.version }} uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: ${{ matrix.version }} - name: Cache pip uses: actions/cache@v3 with: From dc531dc67a70400d4000005d7cbfae5cfc1d77a2 Mon Sep 17 00:00:00 2001 From: Leonardo Taccari Date: Sun, 3 Dec 2023 13:54:59 +0100 Subject: [PATCH 2/3] Switch to use typing.Dict Python 3.8 annotations needs Dict from typing.Dict (i.e. direct `dict` is not usable). Switch to use it in order to be usable from all Python versions. Related/closes #49 and #71. --- transferwee.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/transferwee.py b/transferwee.py index 8815e93..d22889c 100755 --- a/transferwee.py +++ b/transferwee.py @@ -38,7 +38,7 @@ will be shared via emails or link. """ -from typing import Any, List, Optional, Union +from typing import Any, Dict, List, Optional, Union import binascii import functools import hashlib @@ -165,7 +165,7 @@ def download(url: str, file: str = "") -> None: f.write(chunk) -def _file_name_and_size(file: str) -> dict[str, Union[int, str]]: +def _file_name_and_size(file: str) -> Dict[str, Union[int, str]]: """Given a file, prepare the "item_type", "name" and "size" dictionary. Return a dictionary with "item_type", "name" and "size" keys. @@ -216,7 +216,7 @@ def _prepare_email_upload( sender: str, recipients: List[str], session: requests.Session, -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given a list of filenames, message a sender and recipients prepare for the email upload. @@ -237,7 +237,7 @@ def _prepare_email_upload( def _verify_email_upload( transfer_id: str, session: requests.Session -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given a transfer_id, read the code from standard input. Return the parsed JSON response. @@ -260,7 +260,7 @@ def _prepare_link_upload( display_name: str, message: str, session: requests.Session, -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given a list of filenames and a message prepare for the link upload. Return the parsed JSON response. @@ -278,7 +278,7 @@ def _prepare_link_upload( def _storm_urls( authorization: str, -) -> dict[str, str]: +) -> Dict[str, str]: """Given an authorization bearer extract storm URLs. Return a dict with the various storm URLs. @@ -299,7 +299,7 @@ def _storm_urls( def _storm_preflight_item( file: str, -) -> dict[str, Union[List[dict[str, int]], str]]: +) -> Dict[str, Union[List[Dict[str, int]], str]]: """Given a file, prepare the item block dictionary. Return a dictionary with "blocks", "item_type" and "path" keys. @@ -316,7 +316,7 @@ def _storm_preflight_item( def _storm_preflight( authorization: str, filenames: List[str] -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given an Authorization token and filenames do preflight for upload. Return the parsed JSON response. @@ -355,7 +355,7 @@ def _md5(file: str) -> str: return h.hexdigest() -def _storm_prepare_item(file: str) -> dict[str, Union[int, str]]: +def _storm_prepare_item(file: str) -> Dict[str, Union[int, str]]: """Given a file, prepare the block for blocks dictionary. Return a dictionary with "content_length" and "content_md5_hex" keys. @@ -365,7 +365,7 @@ def _storm_prepare_item(file: str) -> dict[str, Union[int, str]]: return {"content_length": filesize, "content_md5_hex": _md5(file)} -def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]: +def _storm_prepare(authorization: str, filenames: List[str]) -> Dict[Any, Any]: """Given an Authorization token and filenames prepare for block uploads. Return the parsed JSON response. @@ -395,7 +395,7 @@ def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]: def _storm_finalize_item( file: str, block_id: str -) -> dict[str, Union[List[str], str]]: +) -> Dict[str, Union[List[str], str]]: """Given a file and block_id prepare the item block dictionary. Return a dictionary with "block_ids", "item_type" and "path" keys. @@ -418,7 +418,7 @@ def _storm_finalize_item( def _storm_finalize( authorization: str, filenames: List[str], block_ids: List[str] -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given an Authorization token, filenames and block ids finalize upload. Return the parsed JSON response. @@ -494,7 +494,7 @@ def _storm_upload(url: str, file: str) -> None: def _finalize_upload( transfer_id: str, session: requests.Session -) -> dict[Any, Any]: +) -> Dict[Any, Any]: """Given a transfer_id finalize the upload. Return the parsed JSON response. From cdcf22aec4b5089e9ad10cae18eb568310a896b7 Mon Sep 17 00:00:00 2001 From: sharevb Date: Sat, 4 Nov 2023 22:27:52 +0100 Subject: [PATCH 3/3] Fix download for go.wetransfer.com links wetransfer now (sometimes) returns short url form in https://go.wetransfer.com/ instead of https://we.tl/ --- transferwee.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transferwee.py b/transferwee.py index d22889c..66f1c2e 100755 --- a/transferwee.py +++ b/transferwee.py @@ -90,7 +90,9 @@ def download_url(url: str) -> Optional[str]: """ logger.debug(f"Getting download URL of {url}") # Follow the redirect if we have a short URL - if url.startswith("https://we.tl/"): + if url.startswith("https://we.tl/") or url.startswith( + "https://go.wetransfer.com/" + ): r = requests.head( url, allow_redirects=True,