yta-fastapi-docker-common 0.0.1__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,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: yta-fastapi-docker-common
3
+ Version: 0.0.1
4
+ Summary: Youtube Autonomous FastAPI Docker Common Module
5
+ License-File: LICENSE
6
+ Author: danialcala94
7
+ Author-email: danielalcalavalera@gmail.com
8
+ Requires-Python: ==3.12.*
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Dist: fastapi (>=0.0.1,<999.0.0)
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Youtube Autonomous FastAPI Docker Common Module
15
+
16
+ The module that is to include code that different projects based on `FastAPI` and `Docker` will use, to avoid duplicities.
17
+
18
+ This project will not include any docker file because it's meant to be used as a simple dependency, but could include some FastAPI dependencies to be able to handle the code we need.
@@ -0,0 +1,5 @@
1
+ # Youtube Autonomous FastAPI Docker Common Module
2
+
3
+ The module that is to include code that different projects based on `FastAPI` and `Docker` will use, to avoid duplicities.
4
+
5
+ This project will not include any docker file because it's meant to be used as a simple dependency, but could include some FastAPI dependencies to be able to handle the code we need.
@@ -0,0 +1,30 @@
1
+ [project]
2
+ name = "yta-fastapi-docker-common"
3
+ version = "0.0.1"
4
+ description = "Youtube Autonomous FastAPI Docker Common Module"
5
+ authors = [
6
+ {name = "danialcala94", email = "danielalcalavalera@gmail.com"}
7
+ ]
8
+ readme = "README.md"
9
+ requires-python = "==3.12.*"
10
+ dependencies = [
11
+ "fastapi (>=0.0.1,<999.0.0)"
12
+ ]
13
+
14
+ [tool.poetry]
15
+ packages = [{include = "yta_fastapi_docker_common", from = "src"}]
16
+
17
+ [tool.poetry.group.dev.dependencies]
18
+ pytest = "^8.3.5"
19
+ httpx = ">=0.0.1"
20
+ yta_testing = ">=0.0.1"
21
+
22
+ [tool.pytest.ini_options]
23
+ markers = [
24
+ "mandatory: mandatory tests for release",
25
+ "additional: exhaustive and demanding tests"
26
+ ]
27
+
28
+ [build-system]
29
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
30
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,35 @@
1
+ """
2
+ The FastAPI and Docker module to share code that
3
+ will be used for the different modules.
4
+ """
5
+ from pathlib import Path
6
+ from typing import Iterator
7
+
8
+
9
+ def stream_response_to_file(
10
+ response: 'Response',
11
+ output_filename: str,
12
+ chunk_size: int = 8192
13
+ ):
14
+ """
15
+ Method to export to a file a response that is
16
+ returning a file content through a generator.
17
+ """
18
+ with Path(output_filename).open('wb') as f:
19
+ for chunk in response.iter_bytes(chunk_size = chunk_size):
20
+ if not isinstance(chunk, (bytes, bytearray)):
21
+ raise TypeError(f'Invalid chunk type: {type(chunk)}')
22
+ f.write(chunk)
23
+
24
+ def stream_to_file(
25
+ stream: Iterator[bytes],
26
+ path: Path
27
+ ):
28
+ """
29
+ Method to export to a file a bytes stream.
30
+ """
31
+ with path.open('wb') as f:
32
+ for chunk in stream:
33
+ if not isinstance(chunk, (bytes, bytearray)):
34
+ raise TypeError(f'Invalid chunk type: {type(chunk)}')
35
+ f.write(chunk)