twat-fs 1.7.5__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.
@@ -0,0 +1,112 @@
1
+ name: Build & Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags-ignore: ["v*"]
7
+ pull_request:
8
+ branches: [main]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: write
13
+ id-token: write
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ quality:
21
+ name: Code Quality
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - name: Checkout code
25
+ uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 0
28
+
29
+ - name: Run Ruff lint
30
+ uses: astral-sh/ruff-action@v3
31
+ with:
32
+ version: "latest"
33
+ args: "check --output-format=github"
34
+
35
+ - name: Run Ruff Format
36
+ uses: astral-sh/ruff-action@v3
37
+ with:
38
+ version: "latest"
39
+ args: "format --check --respect-gitignore"
40
+
41
+ test:
42
+ name: Run Tests
43
+ needs: quality
44
+ strategy:
45
+ matrix:
46
+ python-version: ["3.10", "3.11", "3.12"]
47
+ os: [ubuntu-latest]
48
+ fail-fast: true
49
+ runs-on: ${{ matrix.os }}
50
+ steps:
51
+ - name: Checkout code
52
+ uses: actions/checkout@v4
53
+
54
+ - name: Set up Python
55
+ uses: actions/setup-python@v5
56
+ with:
57
+ python-version: ${{ matrix.python-version }}
58
+
59
+ - name: Install UV
60
+ uses: astral-sh/setup-uv@v5
61
+ with:
62
+ version: "latest"
63
+ python-version: ${{ matrix.python-version }}
64
+ enable-cache: true
65
+ cache-suffix: ${{ matrix.os }}-${{ matrix.python-version }}
66
+
67
+ - name: Install test dependencies
68
+ run: |
69
+ uv pip install --system --upgrade pip
70
+ uv pip install --system ".[test]"
71
+
72
+ - name: Run tests with Pytest
73
+ run: uv run pytest -n auto --maxfail=1 --disable-warnings --cov-report=xml --cov-config=pyproject.toml --cov=src/twat_fs --cov=tests tests/
74
+
75
+ - name: Upload coverage report
76
+ uses: actions/upload-artifact@v4
77
+ with:
78
+ name: coverage-${{ matrix.python-version }}-${{ matrix.os }}
79
+ path: coverage.xml
80
+
81
+ build:
82
+ name: Build Distribution
83
+ needs: test
84
+ runs-on: ubuntu-latest
85
+ steps:
86
+ - name: Checkout code
87
+ uses: actions/checkout@v4
88
+
89
+ - name: Set up Python
90
+ uses: actions/setup-python@v5
91
+ with:
92
+ python-version: "3.12"
93
+
94
+ - name: Install UV
95
+ uses: astral-sh/setup-uv@v5
96
+ with:
97
+ version: "latest"
98
+ python-version: "3.12"
99
+ enable-cache: true
100
+
101
+ - name: Install build tools
102
+ run: uv pip install build hatchling hatch-vcs
103
+
104
+ - name: Build distributions
105
+ run: uv run python -m build --outdir dist
106
+
107
+ - name: Upload distribution artifacts
108
+ uses: actions/upload-artifact@v4
109
+ with:
110
+ name: dist-files
111
+ path: dist/
112
+ retention-days: 5
@@ -0,0 +1,59 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+
11
+ jobs:
12
+ release:
13
+ name: Release to PyPI
14
+ runs-on: ubuntu-latest
15
+ environment:
16
+ name: pypi
17
+ url: https://pypi.org/p/twat-fs
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Set up Python
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.12"
28
+
29
+ - name: Install UV
30
+ uses: astral-sh/setup-uv@v5
31
+ with:
32
+ version: "latest"
33
+ python-version: "3.12"
34
+ enable-cache: true
35
+
36
+ - name: Install build tools
37
+ run: uv pip install build hatchling hatch-vcs
38
+
39
+ - name: Build distributions
40
+ run: uv run python -m build --outdir dist
41
+
42
+ - name: Verify distribution files
43
+ run: |
44
+ ls -la dist/
45
+ test -n "$(find dist -name '*.whl')" || (echo "Wheel file missing" && exit 1)
46
+ test -n "$(find dist -name '*.tar.gz')" || (echo "Source distribution missing" && exit 1)
47
+
48
+ - name: Publish to PyPI
49
+ uses: pypa/gh-action-pypi-publish@release/v1
50
+ with:
51
+ password: ${{ secrets.PYPI_TOKEN }}
52
+
53
+ - name: Create GitHub Release
54
+ uses: softprops/action-gh-release@v1
55
+ with:
56
+ files: dist/*
57
+ generate_release_notes: true
58
+ env:
59
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,315 @@
1
+ *_autogen/
2
+ .DS_Store
3
+ __version__.py
4
+ __pycache__/
5
+ _Chutzpah*
6
+ _deps
7
+ _NCrunch_*
8
+ _pkginfo.txt
9
+ _Pvt_Extensions
10
+ _ReSharper*/
11
+ _TeamCity*
12
+ _UpgradeReport_Files/
13
+ !?*.[Cc]ache/
14
+ !.axoCover/settings.json
15
+ !.vscode/extensions.json
16
+ !.vscode/launch.json
17
+ !.vscode/settings.json
18
+ !.vscode/tasks.json
19
+ !**/[Pp]ackages/build/
20
+ !Directory.Build.rsp
21
+ .*crunch*.local.xml
22
+ .axoCover/*
23
+ .builds
24
+ .cr/personal
25
+ .fake/
26
+ .history/
27
+ .ionide/
28
+ .localhistory/
29
+ .mfractor/
30
+ .ntvs_analysis.dat
31
+ .paket/paket.exe
32
+ .sass-cache/
33
+ .vs/
34
+ .vscode
35
+ .vscode/*
36
+ .vshistory/
37
+ [Aa][Rr][Mm]/
38
+ [Aa][Rr][Mm]64/
39
+ [Bb]in/
40
+ [Bb]uild[Ll]og.*
41
+ [Dd]ebug/
42
+ [Dd]ebugPS/
43
+ [Dd]ebugPublic/
44
+ [Ee]xpress/
45
+ [Ll]og/
46
+ [Ll]ogs/
47
+ [Oo]bj/
48
+ [Rr]elease/
49
+ [Rr]eleasePS/
50
+ [Rr]eleases/
51
+ [Tt]est[Rr]esult*/
52
+ [Ww][Ii][Nn]32/
53
+ *_h.h
54
+ *_i.c
55
+ *_p.c
56
+ *_wpftmp.csproj
57
+ *- [Bb]ackup ([0-9]).rdl
58
+ *- [Bb]ackup ([0-9][0-9]).rdl
59
+ *- [Bb]ackup.rdl
60
+ *.[Cc]ache
61
+ *.[Pp]ublish.xml
62
+ *.[Rr]e[Ss]harper
63
+ *.a
64
+ *.app
65
+ *.appx
66
+ *.appxbundle
67
+ *.appxupload
68
+ *.aps
69
+ *.azurePubxml
70
+ *.bim_*.settings
71
+ *.bim.layout
72
+ *.binlog
73
+ *.btm.cs
74
+ *.btp.cs
75
+ *.build.csdef
76
+ *.cab
77
+ *.cachefile
78
+ *.code-workspace
79
+ *.coverage
80
+ *.coveragexml
81
+ *.d
82
+ *.dbmdl
83
+ *.dbproj.schemaview
84
+ *.dll
85
+ *.dotCover
86
+ *.DotSettings.user
87
+ *.dsp
88
+ *.dsw
89
+ *.dylib
90
+ *.e2e
91
+ *.exe
92
+ *.gch
93
+ *.GhostDoc.xml
94
+ *.gpState
95
+ *.ilk
96
+ *.iobj
97
+ *.ipdb
98
+ *.jfm
99
+ *.jmconfig
100
+ *.la
101
+ *.lai
102
+ *.ldf
103
+ *.lib
104
+ *.lo
105
+ *.log
106
+ *.mdf
107
+ *.meta
108
+ *.mm.*
109
+ *.mod
110
+ *.msi
111
+ *.msix
112
+ *.msm
113
+ *.msp
114
+ *.ncb
115
+ *.ndf
116
+ *.nuget.props
117
+ *.nuget.targets
118
+ *.nupkg
119
+ *.nvuser
120
+ *.o
121
+ *.obj
122
+ *.odx.cs
123
+ *.opendb
124
+ *.opensdf
125
+ *.opt
126
+ *.out
127
+ *.pch
128
+ *.pdb
129
+ *.pfx
130
+ *.pgc
131
+ *.pgd
132
+ *.pidb
133
+ *.plg
134
+ *.psess
135
+ *.publishproj
136
+ *.publishsettings
137
+ *.pubxml
138
+ *.pyc
139
+ *.rdl.data
140
+ *.rptproj.bak
141
+ *.rptproj.rsuser
142
+ *.rsp
143
+ *.rsuser
144
+ *.sap
145
+ *.sbr
146
+ *.scc
147
+ *.sdf
148
+ *.sln.docstates
149
+ *.sln.iml
150
+ *.slo
151
+ *.smod
152
+ *.snupkg
153
+ *.so
154
+ *.suo
155
+ *.svclog
156
+ *.tlb
157
+ *.tlh
158
+ *.tli
159
+ *.tlog
160
+ *.tmp
161
+ *.tmp_proj
162
+ *.tss
163
+ *.user
164
+ *.userosscache
165
+ *.userprefs
166
+ *.vbp
167
+ *.vbw
168
+ *.VC.db
169
+ *.VC.VC.opendb
170
+ *.VisualState.xml
171
+ *.vsp
172
+ *.vspscc
173
+ *.vspx
174
+ *.vssscc
175
+ *.xsd.cs
176
+ **/[Pp]ackages/*
177
+ **/*.DesktopClient/GeneratedArtifacts
178
+ **/*.DesktopClient/ModelManifest.xml
179
+ **/*.HTMLClient/GeneratedArtifacts
180
+ **/*.Server/GeneratedArtifacts
181
+ **/*.Server/ModelManifest.xml
182
+ *~
183
+ ~$*
184
+ $tf/
185
+ AppPackages/
186
+ artifacts/
187
+ ASALocalRun/
188
+ AutoTest.Net/
189
+ Backup*/
190
+ BenchmarkDotNet.Artifacts/
191
+ bld/
192
+ BundleArtifacts/
193
+ ClientBin/
194
+ cmake_install.cmake
195
+ CMakeCache.txt
196
+ CMakeFiles
197
+ CMakeLists.txt.user
198
+ CMakeScripts
199
+ CMakeUserPresets.json
200
+ compile_commands.json
201
+ coverage*.info
202
+ coverage*.json
203
+ coverage*.xml
204
+ csx/
205
+ CTestTestfile.cmake
206
+ dlldata.c
207
+ DocProject/buildhelp/
208
+ DocProject/Help/*.hhc
209
+ DocProject/Help/*.hhk
210
+ DocProject/Help/*.hhp
211
+ DocProject/Help/*.HxC
212
+ DocProject/Help/*.HxT
213
+ DocProject/Help/html
214
+ DocProject/Help/Html2
215
+ ecf/
216
+ FakesAssemblies/
217
+ FodyWeavers.xsd
218
+ Generated_Code/
219
+ Generated\ Files/
220
+ healthchecksdb
221
+ install_manifest.txt
222
+ ipch/
223
+ Makefile
224
+ MigrationBackup/
225
+ mono_crash.*
226
+ nCrunchTemp_*
227
+ node_modules/
228
+ nunit-*.xml
229
+ OpenCover/
230
+ orleans.codegen.cs
231
+ Package.StoreAssociation.xml
232
+ paket-files/
233
+ project.fragment.lock.json
234
+ project.lock.json
235
+ publish/
236
+ PublishScripts/
237
+ rcf/
238
+ ScaffoldingReadMe.txt
239
+ ServiceFabricBackup/
240
+ StyleCopReport.xml
241
+ Testing
242
+ TestResult.xml
243
+ UpgradeLog*.htm
244
+ UpgradeLog*.XML
245
+ x64/
246
+ x86/
247
+ # Python
248
+ __pycache__/
249
+ *.py[cod]
250
+ *$py.class
251
+ *.so
252
+ .Python
253
+ build/
254
+ develop-eggs/
255
+ downloads/
256
+ eggs/
257
+ .eggs/
258
+ lib/
259
+ lib64/
260
+ parts/
261
+ sdist/
262
+ var/
263
+ wheels/
264
+ *.egg-info/
265
+ .installed.cfg
266
+ *.egg
267
+ MANIFEST
268
+
269
+ # Distribution / packaging
270
+ !dist/.gitkeep
271
+
272
+ # Unit test / coverage reports
273
+ htmlcov/
274
+ .tox/
275
+ .nox/
276
+ .coverage
277
+ .coverage.*
278
+ .cache
279
+ nosetests.xml
280
+ coverage.xml
281
+ *.cover
282
+ *.py,cover
283
+ .hypothesis/
284
+ .pytest_cache/
285
+ cover/
286
+ .ruff_cache/
287
+
288
+ # Environments
289
+ .env
290
+ .venv
291
+ env/
292
+ venv/
293
+ ENV/
294
+ env.bak/
295
+ venv.bak/
296
+
297
+ # IDE
298
+ .idea/
299
+ .vscode/
300
+ *.swp
301
+ *.swo
302
+ *~
303
+
304
+ # OS
305
+ .DS_Store
306
+ .DS_Store?
307
+ ._*
308
+ .Spotlight-V100
309
+ .Trashes
310
+ ehthumbs.db
311
+ Thumbs.db
312
+
313
+ # Project specific
314
+ __version__.py
315
+ _private
@@ -0,0 +1,20 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.3.4
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ args: [--respect-gitignore]
9
+ - repo: https://github.com/pre-commit/pre-commit-hooks
10
+ rev: v4.5.0
11
+ hooks:
12
+ - id: trailing-whitespace
13
+ - id: end-of-file-fixer
14
+ - id: check-yaml
15
+ - id: check-toml
16
+ - id: check-added-large-files
17
+ - id: debug-statements
18
+ - id: check-case-conflict
19
+ - id: mixed-line-ending
20
+ args: [--fix=lf]
twat_fs-1.7.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Adam Twardoch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
twat_fs-1.7.5/LOG.md ADDED
@@ -0,0 +1,160 @@
1
+ # LOG
2
+
3
+ ## Completed Work
4
+
5
+ 1. Created file upload functionality with multiple providers:
6
+ - Created `src/twat_fs/upload_providers/` directory
7
+ - Implemented `fal.py` provider with simple file upload functionality
8
+ - Adapted private Dropbox implementation into `dropbox.py` provider
9
+ - Created main `upload.py` module with provider selection logic
10
+ - Added S3 provider with AWS S3 upload functionality
11
+
12
+ 2. Implemented CLI interface:
13
+ - Created `__main__.py` with Fire CLI integration
14
+ - Added `upload_file` command with provider selection
15
+ - Updated `__init__.py` to expose main functionality
16
+
17
+ 3. Updated documentation:
18
+ - Added new functionality to README.md
19
+ - Documented provider configuration
20
+ - Added usage examples for both Python API and CLI
21
+
22
+ 4. Enhanced provider functionality:
23
+ - Added `provider_auth` functions to check authentication
24
+ - Added loguru warnings for missing credentials
25
+ - Implemented provider fallback mechanism
26
+ - Added support for provider lists and preferences
27
+ - Added S3 as the default preferred provider
28
+
29
+ 5. Created test framework:
30
+ - Added comprehensive test skeleton in `tests/test_upload.py`
31
+ - Created test fixtures and mocks
32
+ - Added test data directory
33
+ - Implemented tests for auth, upload, and fallback functionality
34
+ - Added S3-specific tests for authentication and upload scenarios
35
+ - Added integration tests with real providers in `test_integration.py`
36
+ - Added edge cases and error condition tests
37
+ - Added performance tests with different file sizes
38
+ - Added tests for S3 multipart uploads
39
+ - Added tests for different S3 endpoint configurations
40
+ - Added tests for various AWS credential providers
41
+
42
+ 6. Refactored provider authentication and initialization:
43
+ - Split provider initialization into two steps:
44
+ 1. `get_credentials`: Simple function to check and return required env variables
45
+ 2. `get_provider`: Function to import dependencies and initialize provider client
46
+ - Updated all providers (S3, FAL, Dropbox) to use the new pattern
47
+ - Added proper typing and error handling
48
+ - Improved logging and error messages
49
+ - Made provider initialization more efficient by checking credentials before importing dependencies
50
+ - Updated main upload module to use the new provider pattern
51
+ - Added better provider client management
52
+
53
+ 7. Added provider setup functionality:
54
+ - Implemented `setup_provider` function to check individual provider status
55
+ - Added `setup_providers` function to check all available providers
56
+ - Added detailed help messages for each provider's setup requirements
57
+ - Added dependency installation instructions
58
+ - Updated all tests to use the new provider pattern:
59
+ - Updated unit tests in `test_upload.py`
60
+ - Updated integration tests in `test_integration.py`
61
+ - Updated S3 advanced tests in `test_s3_advanced.py`
62
+ - Added new test cases for provider setup
63
+ - Improved error messages and setup instructions
64
+ - Added comprehensive credential configuration guides
65
+ - Added CLI commands for checking provider setup:
66
+ - `setup provider <name>`: Check setup status for a specific provider
67
+ - `setup all`: Check setup status for all available providers
68
+
69
+ 8. Improved provider interface and type system:
70
+ - Created formal provider interfaces using Python's Protocol system:
71
+ - `Provider` protocol defining what each provider module must implement
72
+ - `ProviderClient` protocol defining what each provider's client must implement
73
+ - Added runtime protocol checking with `@runtime_checkable`
74
+ - Moved provider-specific help messages to their respective provider modules
75
+ - Created a centralized provider registry in `upload_providers/__init__.py`:
76
+ - Added `ProviderType` that automatically stays in sync with available providers
77
+ - Added lazy loading of provider modules with caching
78
+ - Added proper type hints and documentation for all interfaces
79
+ - Improved type safety throughout the codebase:
80
+ - Added proper return type hints for all functions
81
+ - Added TypedDict for provider help messages
82
+ - Added better error handling for protocol violations
83
+ - Made the provider system more maintainable:
84
+ - Single source of truth for provider list
85
+ - Self-documenting interfaces
86
+ - Better IDE support through type hints
87
+ - Clearer separation between module and client interfaces
88
+
89
+ ## TODO4:
90
+
91
+ 1. ✅ Provider API Improvements (Completed in update 8):
92
+ - Created formal provider interface using Protocol system
93
+ - Added provider discovery with lazy loading
94
+ - Implemented runtime protocol checking
95
+ - Added comprehensive type hints
96
+ - Moved provider-specific help messages to modules
97
+ - Created centralized provider registry
98
+
99
+ 2. Improve S3 provider API:
100
+ - Add specific error types for S3-related failures:
101
+ - Create custom exception hierarchy
102
+ - Map AWS error codes to specific exceptions
103
+ - Add detailed error messages and recovery hints
104
+ - Add support for advanced AWS authentication:
105
+ - IAM roles and instance profiles
106
+ - AWS SSO credentials
107
+ - Role assumption and chaining
108
+ - Enhance S3 functionality:
109
+ - Add support for bucket policies and ACLs
110
+ - Implement S3 transfer acceleration
111
+ - Add credential caching mechanism
112
+ - Add support for S3-compatible services
113
+ - Improve multipart uploads:
114
+ - Add progress tracking
115
+ - Add resume capability
116
+ - Add parallel upload support
117
+ - Add automatic retries
118
+
119
+ 3. Enhance error handling and logging:
120
+ - Replace broad exception catches (BLE001)
121
+ - Add structured error logging
122
+ - Improve error recovery mechanisms
123
+ - Add detailed troubleshooting guides
124
+
125
+ 4. Improve code quality:
126
+ - Fix linter warnings about complexity
127
+ - Refactor boolean arguments to use enums/options
128
+ - Add more comprehensive integration tests
129
+ - Add performance benchmarks
130
+
131
+ # Development Log
132
+
133
+ ## 2025-02-14
134
+
135
+ ### Changes Made
136
+ - Updated the main upload_file function to add proper file validation checks (existence, type, permissions)
137
+ - Modified _try_provider helper to properly handle remote_path parameter
138
+ - Revised FAL provider to handle missing set_key method gracefully
139
+ - Fixed S3 provider implementation:
140
+ - Added proper credentials handling
141
+ - Improved multipart upload with abort on failure
142
+ - Fixed config handling for path-style endpoints
143
+ - Added better error handling and logging
144
+ - Implemented formal provider interface using Python's Protocol system
145
+ - Added runtime protocol checking for better error detection
146
+ - Moved provider-specific help messages to their respective modules
147
+ - Created centralized provider registry with lazy loading
148
+ - Added comprehensive type hints and documentation
149
+ - Fixed S3 multipart upload tests:
150
+ - Corrected mocking strategy for boto3.client
151
+ - Fixed test function calls to use correct module path
152
+ - Improved test assertions and error handling
153
+ - Added better test documentation
154
+
155
+ ### Next Steps
156
+ - Refactor broad exception catches (BLE001)
157
+ - Fix linter warnings about complexity and boolean args
158
+ - Review and update Dropbox provider if needed
159
+ - Add more comprehensive integration tests
160
+ - Improve error messages and logging