gmt-python-sdk 0.35.1__tar.gz → 0.37.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gmt_python_sdk-0.37.0/.release-please-manifest.json +3 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/CHANGELOG.md +31 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/PKG-INFO +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/pyproject.toml +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_client.py +23 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_files.py +53 -3
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_qs.py +2 -6
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_types.py +3 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/__init__.py +0 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_utils.py +34 -23
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_version.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/purchases.py +2 -2
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_create_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_list_params.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_list_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_refund_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_request_verification_code_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_retrieve_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_create_response.py +2 -2
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_retrieve_response.py +2 -2
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_request_verification_code_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_retrieve_response.py +1 -1
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_extract_files.py +23 -5
- gmt_python_sdk-0.37.0/tests/test_files.py +148 -0
- gmt_python_sdk-0.35.1/.release-please-manifest.json +0 -3
- gmt_python_sdk-0.35.1/tests/test_deepcopy.py +0 -58
- gmt_python_sdk-0.35.1/tests/test_files.py +0 -51
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/.gitignore +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/CONTRIBUTING.md +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/LICENSE +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/README.md +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/SECURITY.md +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/api.md +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/bin/check-release-environment +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/bin/publish-pypi +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/examples/.keep +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/release-please-config.json +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/requirements-dev.lock +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_base_client.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_compat.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_constants.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_exceptions.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_models.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_resource.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_streaming.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_compat.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_datetime_parse.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_json.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_logs.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_path.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_proxy.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_reflection.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_resources_proxy.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_streams.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_sync.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_transform.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_typing.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/lib/.keep +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/pagination.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/py.typed +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/accounts.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/discount.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/profile.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/referral.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/transaction.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/bulk.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases_by_hash.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/service.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/purchases.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/telegram.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/resources/webhooks.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_countries_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_countries_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/account_retrieve_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/discount_retrieve_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/transaction_list_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/transaction_list_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_retrieve_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_transfer_balance_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_transfer_balance_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_login_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_login_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_password_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_password_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_retrieve_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_unbind_telegram_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_create_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_request_verification_code_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_create_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_request_verification_code_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/service_get_server_time_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/service_health_check_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_premium_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_premium_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_stars_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_stars_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_premium_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_premium_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_stars_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_stars_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_premium_price_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_premium_price_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_stars_price_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_stars_price_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/webhook_test_params.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/webhook_test_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/referral/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/referral/test_transaction.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/test_discount.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/test_referral.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/purchases/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/purchases/test_bulk.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/telegram/__init__.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/telegram/test_purchases.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_accounts.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_profile.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_purchases.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_purchases_by_hash.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_service.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_telegram.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/api_resources/test_webhooks.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/conftest.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/sample_file.txt +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_client.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_models.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_qs.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_required_args.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_response.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_streaming.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_transform.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_utils/test_json.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_utils/test_path.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_utils/test_proxy.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/test_utils/test_typing.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/tests/utils.py +0 -0
- {gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/uv.lock +0 -0
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.37.0 (2026-04-28)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.36.0...v0.37.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.36.0...v0.37.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* support setting headers via env ([c55427d](https://github.com/cameo6/gmt-python-sdk/commit/c55427de52cb37445691ee9be890e94144394e3c))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* use correct field name format for multipart file arrays ([ddbca94](https://github.com/cameo6/gmt-python-sdk/commit/ddbca94beeb11a9012d71d216788d4906dd8880e))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Performance Improvements
|
|
18
|
+
|
|
19
|
+
* **client:** optimize file structure copying in multipart requests ([7a46aa1](https://github.com/cameo6/gmt-python-sdk/commit/7a46aa13908eb43a8f5d2d004a938ea604e22f4a))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Chores
|
|
23
|
+
|
|
24
|
+
* **internal:** more robust bootstrap script ([1248c86](https://github.com/cameo6/gmt-python-sdk/commit/1248c865522e5e041927e73fac626d2cb7acf234))
|
|
25
|
+
|
|
26
|
+
## 0.36.0 (2026-04-11)
|
|
27
|
+
|
|
28
|
+
Full Changelog: [v0.35.1...v0.36.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.35.1...v0.36.0)
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* **api:** api update ([8a698e3](https://github.com/cameo6/gmt-python-sdk/commit/8a698e3b7766f2a73b6d555df4f00c1579ce110d))
|
|
33
|
+
|
|
3
34
|
## 0.35.1 (2026-04-11)
|
|
4
35
|
|
|
5
36
|
Full Changelog: [v0.35.0...v0.35.1](https://github.com/cameo6/gmt-python-sdk/compare/v0.35.0...v0.35.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: gmt-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.37.0
|
|
4
4
|
Summary: The official Python library for the gmt API
|
|
5
5
|
Project-URL: Homepage, https://github.com/cameo6/gmt-python-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/cameo6/gmt-python-sdk
|
|
@@ -19,7 +19,11 @@ from ._types import (
|
|
|
19
19
|
RequestOptions,
|
|
20
20
|
not_given,
|
|
21
21
|
)
|
|
22
|
-
from ._utils import
|
|
22
|
+
from ._utils import (
|
|
23
|
+
is_given,
|
|
24
|
+
is_mapping_t,
|
|
25
|
+
get_async_library,
|
|
26
|
+
)
|
|
23
27
|
from ._compat import cached_property
|
|
24
28
|
from ._version import __version__
|
|
25
29
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
@@ -83,6 +87,15 @@ class Gmt(SyncAPIClient):
|
|
|
83
87
|
if base_url is None:
|
|
84
88
|
base_url = f"https://api.getmytg.com"
|
|
85
89
|
|
|
90
|
+
custom_headers_env = os.environ.get("GMT_CUSTOM_HEADERS")
|
|
91
|
+
if custom_headers_env is not None:
|
|
92
|
+
parsed: dict[str, str] = {}
|
|
93
|
+
for line in custom_headers_env.split("\n"):
|
|
94
|
+
colon = line.find(":")
|
|
95
|
+
if colon >= 0:
|
|
96
|
+
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
|
|
97
|
+
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
|
|
98
|
+
|
|
86
99
|
super().__init__(
|
|
87
100
|
version=__version__,
|
|
88
101
|
base_url=base_url,
|
|
@@ -329,6 +342,15 @@ class AsyncGmt(AsyncAPIClient):
|
|
|
329
342
|
if base_url is None:
|
|
330
343
|
base_url = f"https://api.getmytg.com"
|
|
331
344
|
|
|
345
|
+
custom_headers_env = os.environ.get("GMT_CUSTOM_HEADERS")
|
|
346
|
+
if custom_headers_env is not None:
|
|
347
|
+
parsed: dict[str, str] = {}
|
|
348
|
+
for line in custom_headers_env.split("\n"):
|
|
349
|
+
colon = line.find(":")
|
|
350
|
+
if colon >= 0:
|
|
351
|
+
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
|
|
352
|
+
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
|
|
353
|
+
|
|
332
354
|
super().__init__(
|
|
333
355
|
version=__version__,
|
|
334
356
|
base_url=base_url,
|
|
@@ -3,8 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
import io
|
|
4
4
|
import os
|
|
5
5
|
import pathlib
|
|
6
|
-
from typing import overload
|
|
7
|
-
from typing_extensions import TypeGuard
|
|
6
|
+
from typing import Sequence, cast, overload
|
|
7
|
+
from typing_extensions import TypeVar, TypeGuard
|
|
8
8
|
|
|
9
9
|
import anyio
|
|
10
10
|
|
|
@@ -17,7 +17,9 @@ from ._types import (
|
|
|
17
17
|
HttpxFileContent,
|
|
18
18
|
HttpxRequestFiles,
|
|
19
19
|
)
|
|
20
|
-
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
|
|
20
|
+
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t
|
|
21
|
+
|
|
22
|
+
_T = TypeVar("_T")
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
|
|
@@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
|
|
|
121
123
|
return await anyio.Path(file).read_bytes()
|
|
122
124
|
|
|
123
125
|
return file
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
|
|
129
|
+
"""Copy only the containers along the given paths.
|
|
130
|
+
|
|
131
|
+
Used to guard against mutation by extract_files without copying the entire structure.
|
|
132
|
+
Only dicts and lists that lie on a path are copied; everything else
|
|
133
|
+
is returned by reference.
|
|
134
|
+
|
|
135
|
+
For example, given paths=[["foo", "files", "file"]] and the structure:
|
|
136
|
+
{
|
|
137
|
+
"foo": {
|
|
138
|
+
"bar": {"baz": {}},
|
|
139
|
+
"files": {"file": <content>}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
The root dict, "foo", and "files" are copied (they lie on the path).
|
|
143
|
+
"bar" and "baz" are returned by reference (off the path).
|
|
144
|
+
"""
|
|
145
|
+
return _deepcopy_with_paths(item, paths, 0)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
|
|
149
|
+
if not paths:
|
|
150
|
+
return item
|
|
151
|
+
if is_mapping(item):
|
|
152
|
+
key_to_paths: dict[str, list[Sequence[str]]] = {}
|
|
153
|
+
for path in paths:
|
|
154
|
+
if index < len(path):
|
|
155
|
+
key_to_paths.setdefault(path[index], []).append(path)
|
|
156
|
+
|
|
157
|
+
# if no path continues through this mapping, it won't be mutated and copying it is redundant
|
|
158
|
+
if not key_to_paths:
|
|
159
|
+
return item
|
|
160
|
+
|
|
161
|
+
result = dict(item)
|
|
162
|
+
for key, subpaths in key_to_paths.items():
|
|
163
|
+
if key in result:
|
|
164
|
+
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
|
|
165
|
+
return cast(_T, result)
|
|
166
|
+
if is_list(item):
|
|
167
|
+
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]
|
|
168
|
+
|
|
169
|
+
# if no path expects a list here, nothing will be mutated inside it - return by reference
|
|
170
|
+
if not array_paths:
|
|
171
|
+
return cast(_T, item)
|
|
172
|
+
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
|
|
173
|
+
return item
|
|
@@ -2,17 +2,13 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, List, Tuple, Union, Mapping, TypeVar
|
|
4
4
|
from urllib.parse import parse_qs, urlencode
|
|
5
|
-
from typing_extensions import
|
|
5
|
+
from typing_extensions import get_args
|
|
6
6
|
|
|
7
|
-
from ._types import NotGiven, not_given
|
|
7
|
+
from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
|
|
8
8
|
from ._utils import flatten
|
|
9
9
|
|
|
10
10
|
_T = TypeVar("_T")
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
|
|
14
|
-
NestedFormat = Literal["dots", "brackets"]
|
|
15
|
-
|
|
16
12
|
PrimitiveData = Union[str, int, float, bool, None]
|
|
17
13
|
# this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
|
|
18
14
|
# https://github.com/microsoft/pyright/issues/3555
|
|
@@ -47,6 +47,9 @@ AnyMapping = Mapping[str, object]
|
|
|
47
47
|
ModelT = TypeVar("ModelT", bound=pydantic.BaseModel)
|
|
48
48
|
_T = TypeVar("_T")
|
|
49
49
|
|
|
50
|
+
ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
|
|
51
|
+
NestedFormat = Literal["dots", "brackets"]
|
|
52
|
+
|
|
50
53
|
|
|
51
54
|
# Approximates httpx internal ProxiesTypes and RequestFiles types
|
|
52
55
|
# while adding support for `PathLike` instances
|
|
@@ -24,7 +24,6 @@ from ._utils import (
|
|
|
24
24
|
coerce_integer as coerce_integer,
|
|
25
25
|
file_from_path as file_from_path,
|
|
26
26
|
strip_not_given as strip_not_given,
|
|
27
|
-
deepcopy_minimal as deepcopy_minimal,
|
|
28
27
|
get_async_library as get_async_library,
|
|
29
28
|
maybe_coerce_float as maybe_coerce_float,
|
|
30
29
|
get_required_header as get_required_header,
|
|
@@ -17,11 +17,11 @@ from typing import (
|
|
|
17
17
|
)
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from datetime import date, datetime
|
|
20
|
-
from typing_extensions import TypeGuard
|
|
20
|
+
from typing_extensions import TypeGuard, get_args
|
|
21
21
|
|
|
22
22
|
import sniffio
|
|
23
23
|
|
|
24
|
-
from .._types import Omit, NotGiven, FileTypes, HeadersLike
|
|
24
|
+
from .._types import Omit, NotGiven, FileTypes, ArrayFormat, HeadersLike
|
|
25
25
|
|
|
26
26
|
_T = TypeVar("_T")
|
|
27
27
|
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
|
|
@@ -40,25 +40,45 @@ def extract_files(
|
|
|
40
40
|
query: Mapping[str, object],
|
|
41
41
|
*,
|
|
42
42
|
paths: Sequence[Sequence[str]],
|
|
43
|
+
array_format: ArrayFormat = "brackets",
|
|
43
44
|
) -> list[tuple[str, FileTypes]]:
|
|
44
45
|
"""Recursively extract files from the given dictionary based on specified paths.
|
|
45
46
|
|
|
46
47
|
A path may look like this ['foo', 'files', '<array>', 'data'].
|
|
47
48
|
|
|
49
|
+
``array_format`` controls how ``<array>`` segments contribute to the emitted
|
|
50
|
+
field name. Supported values: ``"brackets"`` (``foo[]``), ``"repeat"`` and
|
|
51
|
+
``"comma"`` (``foo``), ``"indices"`` (``foo[0]``, ``foo[1]``).
|
|
52
|
+
|
|
48
53
|
Note: this mutates the given dictionary.
|
|
49
54
|
"""
|
|
50
55
|
files: list[tuple[str, FileTypes]] = []
|
|
51
56
|
for path in paths:
|
|
52
|
-
files.extend(_extract_items(query, path, index=0, flattened_key=None))
|
|
57
|
+
files.extend(_extract_items(query, path, index=0, flattened_key=None, array_format=array_format))
|
|
53
58
|
return files
|
|
54
59
|
|
|
55
60
|
|
|
61
|
+
def _array_suffix(array_format: ArrayFormat, array_index: int) -> str:
|
|
62
|
+
if array_format == "brackets":
|
|
63
|
+
return "[]"
|
|
64
|
+
if array_format == "indices":
|
|
65
|
+
return f"[{array_index}]"
|
|
66
|
+
if array_format == "repeat" or array_format == "comma":
|
|
67
|
+
# Both repeat the bare field name for each file part; there is no
|
|
68
|
+
# meaningful way to comma-join binary parts.
|
|
69
|
+
return ""
|
|
70
|
+
raise NotImplementedError(
|
|
71
|
+
f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
56
75
|
def _extract_items(
|
|
57
76
|
obj: object,
|
|
58
77
|
path: Sequence[str],
|
|
59
78
|
*,
|
|
60
79
|
index: int,
|
|
61
80
|
flattened_key: str | None,
|
|
81
|
+
array_format: ArrayFormat,
|
|
62
82
|
) -> list[tuple[str, FileTypes]]:
|
|
63
83
|
try:
|
|
64
84
|
key = path[index]
|
|
@@ -75,9 +95,11 @@ def _extract_items(
|
|
|
75
95
|
|
|
76
96
|
if is_list(obj):
|
|
77
97
|
files: list[tuple[str, FileTypes]] = []
|
|
78
|
-
for entry in obj:
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
for array_index, entry in enumerate(obj):
|
|
99
|
+
suffix = _array_suffix(array_format, array_index)
|
|
100
|
+
emitted_key = (flattened_key + suffix) if flattened_key else suffix
|
|
101
|
+
assert_is_file_content(entry, key=emitted_key)
|
|
102
|
+
files.append((emitted_key, cast(FileTypes, entry)))
|
|
81
103
|
return files
|
|
82
104
|
|
|
83
105
|
assert_is_file_content(obj, key=flattened_key)
|
|
@@ -106,6 +128,7 @@ def _extract_items(
|
|
|
106
128
|
path,
|
|
107
129
|
index=index,
|
|
108
130
|
flattened_key=flattened_key,
|
|
131
|
+
array_format=array_format,
|
|
109
132
|
)
|
|
110
133
|
elif is_list(obj):
|
|
111
134
|
if key != "<array>":
|
|
@@ -117,9 +140,12 @@ def _extract_items(
|
|
|
117
140
|
item,
|
|
118
141
|
path,
|
|
119
142
|
index=index,
|
|
120
|
-
flattened_key=
|
|
143
|
+
flattened_key=(
|
|
144
|
+
(flattened_key if flattened_key is not None else "") + _array_suffix(array_format, array_index)
|
|
145
|
+
),
|
|
146
|
+
array_format=array_format,
|
|
121
147
|
)
|
|
122
|
-
for item in obj
|
|
148
|
+
for array_index, item in enumerate(obj)
|
|
123
149
|
]
|
|
124
150
|
)
|
|
125
151
|
|
|
@@ -177,21 +203,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
|
|
|
177
203
|
return isinstance(obj, Iterable)
|
|
178
204
|
|
|
179
205
|
|
|
180
|
-
def deepcopy_minimal(item: _T) -> _T:
|
|
181
|
-
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
|
|
182
|
-
|
|
183
|
-
- mappings, e.g. `dict`
|
|
184
|
-
- list
|
|
185
|
-
|
|
186
|
-
This is done for performance reasons.
|
|
187
|
-
"""
|
|
188
|
-
if is_mapping(item):
|
|
189
|
-
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
|
|
190
|
-
if is_list(item):
|
|
191
|
-
return cast(_T, [deepcopy_minimal(entry) for entry in item])
|
|
192
|
-
return item
|
|
193
|
-
|
|
194
|
-
|
|
195
206
|
# copied from https://github.com/Rapptz/RoboDanny
|
|
196
207
|
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
|
|
197
208
|
size = len(seq)
|
|
@@ -155,7 +155,7 @@ class PurchasesResource(SyncAPIResource):
|
|
|
155
155
|
page_size: int,
|
|
156
156
|
sort: Literal["date_asc", "date_desc"],
|
|
157
157
|
phone_number: str | Omit = omit,
|
|
158
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"] | Omit = omit,
|
|
158
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"] | Omit = omit,
|
|
159
159
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
160
160
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
161
161
|
extra_headers: Headers | None = None,
|
|
@@ -456,7 +456,7 @@ class AsyncPurchasesResource(AsyncAPIResource):
|
|
|
456
456
|
page_size: int,
|
|
457
457
|
sort: Literal["date_asc", "date_desc"],
|
|
458
458
|
phone_number: str | Omit = omit,
|
|
459
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"] | Omit = omit,
|
|
459
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"] | Omit = omit,
|
|
460
460
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
461
461
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
462
462
|
extra_headers: Headers | None = None,
|
|
@@ -105,7 +105,7 @@ class PurchaseCreateResponse(BaseModel):
|
|
|
105
105
|
deduction)
|
|
106
106
|
"""
|
|
107
107
|
|
|
108
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
108
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
109
109
|
"""
|
|
110
110
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
111
111
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -23,7 +23,7 @@ class PurchaseListParams(TypedDict, total=False):
|
|
|
23
23
|
Example: '123' matches '+71234567890'.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
26
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
27
27
|
"""
|
|
28
28
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
29
29
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -105,7 +105,7 @@ class PurchaseListResponse(BaseModel):
|
|
|
105
105
|
deduction)
|
|
106
106
|
"""
|
|
107
107
|
|
|
108
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
108
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
109
109
|
"""
|
|
110
110
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
111
111
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -113,7 +113,7 @@ class Purchase(BaseModel):
|
|
|
113
113
|
deduction)
|
|
114
114
|
"""
|
|
115
115
|
|
|
116
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
116
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
117
117
|
"""
|
|
118
118
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
119
119
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -129,7 +129,7 @@ class Purchase(BaseModel):
|
|
|
129
129
|
deduction)
|
|
130
130
|
"""
|
|
131
131
|
|
|
132
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
132
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
133
133
|
"""
|
|
134
134
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
135
135
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -105,7 +105,7 @@ class PurchaseRetrieveResponse(BaseModel):
|
|
|
105
105
|
deduction)
|
|
106
106
|
"""
|
|
107
107
|
|
|
108
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
108
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
109
109
|
"""
|
|
110
110
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
111
111
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
{gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_create_response.py
RENAMED
|
@@ -23,7 +23,7 @@ class Item(BaseModel):
|
|
|
23
23
|
quantity: int
|
|
24
24
|
"""Number of accounts in the archive"""
|
|
25
25
|
|
|
26
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
26
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
27
27
|
"""Status of bulk purchase"""
|
|
28
28
|
|
|
29
29
|
|
|
@@ -66,7 +66,7 @@ class BulkCreateResponse(BaseModel):
|
|
|
66
66
|
quantity: int
|
|
67
67
|
"""Number of accounts in this purchase"""
|
|
68
68
|
|
|
69
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
69
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
70
70
|
"""Current status of bulk purchase"""
|
|
71
71
|
|
|
72
72
|
total_price: TotalPrice
|
{gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_retrieve_response.py
RENAMED
|
@@ -23,7 +23,7 @@ class Item(BaseModel):
|
|
|
23
23
|
quantity: int
|
|
24
24
|
"""Number of accounts in the archive"""
|
|
25
25
|
|
|
26
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
26
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
27
27
|
"""Status of bulk purchase"""
|
|
28
28
|
|
|
29
29
|
|
|
@@ -66,7 +66,7 @@ class BulkRetrieveResponse(BaseModel):
|
|
|
66
66
|
quantity: int
|
|
67
67
|
"""Number of accounts in this purchase"""
|
|
68
68
|
|
|
69
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
69
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
70
70
|
"""Current status of bulk purchase"""
|
|
71
71
|
|
|
72
72
|
total_price: TotalPrice
|
|
@@ -129,7 +129,7 @@ class Purchase(BaseModel):
|
|
|
129
129
|
deduction)
|
|
130
130
|
"""
|
|
131
131
|
|
|
132
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
132
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
133
133
|
"""
|
|
134
134
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
135
135
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
{gmt_python_sdk-0.35.1 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_retrieve_response.py
RENAMED
|
@@ -105,7 +105,7 @@ class PurchasesByHashRetrieveResponse(BaseModel):
|
|
|
105
105
|
deduction)
|
|
106
106
|
"""
|
|
107
107
|
|
|
108
|
-
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"]
|
|
108
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND", "EXPIRED"]
|
|
109
109
|
"""
|
|
110
110
|
**Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
111
111
|
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
@@ -4,7 +4,7 @@ from typing import Sequence
|
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
|
|
7
|
-
from gmt._types import FileTypes
|
|
7
|
+
from gmt._types import FileTypes, ArrayFormat
|
|
8
8
|
from gmt._utils import extract_files
|
|
9
9
|
|
|
10
10
|
|
|
@@ -37,10 +37,7 @@ def test_multiple_files() -> None:
|
|
|
37
37
|
|
|
38
38
|
def test_top_level_file_array() -> None:
|
|
39
39
|
query = {"files": [b"file one", b"file two"], "title": "hello"}
|
|
40
|
-
assert extract_files(query, paths=[["files", "<array>"]]) == [
|
|
41
|
-
("files[]", b"file one"),
|
|
42
|
-
("files[]", b"file two"),
|
|
43
|
-
]
|
|
40
|
+
assert extract_files(query, paths=[["files", "<array>"]]) == [("files[]", b"file one"), ("files[]", b"file two")]
|
|
44
41
|
assert query == {"title": "hello"}
|
|
45
42
|
|
|
46
43
|
|
|
@@ -71,3 +68,24 @@ def test_ignores_incorrect_paths(
|
|
|
71
68
|
expected: list[tuple[str, FileTypes]],
|
|
72
69
|
) -> None:
|
|
73
70
|
assert extract_files(query, paths=paths) == expected
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize(
|
|
74
|
+
"array_format,expected_top_level,expected_nested",
|
|
75
|
+
[
|
|
76
|
+
("brackets", [("files[]", b"a"), ("files[]", b"b")], [("items[][file]", b"a"), ("items[][file]", b"b")]),
|
|
77
|
+
("repeat", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]),
|
|
78
|
+
("comma", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]),
|
|
79
|
+
("indices", [("files[0]", b"a"), ("files[1]", b"b")], [("items[0][file]", b"a"), ("items[1][file]", b"b")]),
|
|
80
|
+
],
|
|
81
|
+
)
|
|
82
|
+
def test_array_format_controls_file_field_names(
|
|
83
|
+
array_format: ArrayFormat,
|
|
84
|
+
expected_top_level: list[tuple[str, FileTypes]],
|
|
85
|
+
expected_nested: list[tuple[str, FileTypes]],
|
|
86
|
+
) -> None:
|
|
87
|
+
top_level = {"files": [b"a", b"b"]}
|
|
88
|
+
assert extract_files(top_level, paths=[["files", "<array>"]], array_format=array_format) == expected_top_level
|
|
89
|
+
|
|
90
|
+
nested = {"items": [{"file": b"a"}, {"file": b"b"}]}
|
|
91
|
+
assert extract_files(nested, paths=[["items", "<array>", "file"]], array_format=array_format) == expected_nested
|