fificore 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.
fificore-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FiFi Sayad
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.
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: fificore
3
+ Version: 0.0.1
4
+ Summary: FiFi Core is full of tools
5
+ Author-email: FiFi <sayad.mehrdad@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 FiFi Sayad
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/fifisayad/FiFiCore.git
29
+ Keywords: core,db,utility
30
+ Classifier: Programming Language :: Python
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.12.0
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: SQLAlchemy
37
+ Provides-Extra: dev
38
+ Requires-Dist: black; extra == "dev"
39
+ Requires-Dist: bumpver; extra == "dev"
40
+ Requires-Dist: isort; extra == "dev"
41
+ Requires-Dist: pip-tools; extra == "dev"
42
+ Requires-Dist: pytest; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # FiFiCore
46
+ Repo consists of repeatative functionality across different projects which can use
47
+ this core library.
@@ -0,0 +1,3 @@
1
+ # FiFiCore
2
+ Repo consists of repeatative functionality across different projects which can use
3
+ this core library.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fificore"
7
+ version = "0.0.1"
8
+ description = "FiFi Core is full of tools"
9
+ readme = "README.md"
10
+ authors = [
11
+ { name = "FiFi", email = "sayad.mehrdad@gmail.com" },
12
+ ]
13
+ license = { file = "LICENSE" }
14
+ classifiers = [
15
+ "Programming Language :: Python",
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ keywords = ["core", "db", "utility"]
20
+ dependencies = [
21
+ "SQLAlchemy",
22
+ ]
23
+ requires-python = ">=3.12.0"
24
+
25
+ [project.optional-dependencies]
26
+ dev = ["black", "bumpver", "isort", "pip-tools", "pytest"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/fifisayad/FiFiCore.git"
30
+
31
+ [project.scripts]
32
+ # realpython = "reader.__main__:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ __all__ = ["EngineBase", "DBAsyncSessionInjection", "singleton", "timeit_log"]
2
+
3
+ from .database.engine_base import EngineBase
4
+ from .decorator.db_async_session_injection import DBAsyncSessionInjection
5
+ from .decorator.singleton import singleton
6
+ from .decorator.time_log import timeit_log
@@ -0,0 +1,33 @@
1
+ from abc import ABC
2
+
3
+ from sqlalchemy.orm import sessionmaker
4
+ from sqlalchemy.ext.asyncio import AsyncEngine
5
+
6
+
7
+ class EngineBase(ABC):
8
+ """
9
+ This is a abstract class for providing enginge to database we consider it.
10
+ """
11
+
12
+ engine: AsyncEngine
13
+ session_maker: sessionmaker
14
+
15
+ def __init__(self):
16
+ """__init__.
17
+ in this method we initiliaze our database engine and
18
+ init our sessionmaker class in terms of passing to session injection
19
+ self.engine = create_async_engine(
20
+ url="postgresql+psycopg://{}:{}@{}:{}/{}".format(
21
+ postgres_data.user,
22
+ postgres_data.password,
23
+ postgres_data.host,
24
+ postgres_data.port,
25
+ postgres_data.db,
26
+ ),
27
+ echo=False,
28
+ pool_pre_ping=True,
29
+ )
30
+ self.session_maker = sessionmaker(self.engine, class_=AsyncSession, expire_on_commit=False)
31
+ DecoratedBase.metadata.create_all(self.engine)
32
+ """
33
+ pass
@@ -0,0 +1,23 @@
1
+ import functools
2
+ from sqlalchemy.orm import sessionmaker
3
+
4
+
5
+ class DBAsyncSessionInjection:
6
+
7
+ @staticmethod
8
+ def inject_async_session(session_maker: sessionmaker):
9
+ def decorator(func):
10
+ @functools.wraps(func)
11
+ async def wrapper(*args, **kwargs):
12
+ async with session_maker() as session:
13
+ try:
14
+ result = await func(*args, session=session, **kwargs)
15
+ await session.commit()
16
+ return result
17
+ except Exception:
18
+ await session.rollback()
19
+ raise
20
+
21
+ return wrapper
22
+
23
+ return decorator
@@ -0,0 +1,15 @@
1
+ import functools
2
+
3
+
4
+ def singleton(cls):
5
+ """Turns class into singleton"""
6
+
7
+ @functools.wraps(cls)
8
+ def wrapper(*args, **kwargs):
9
+ if wrapper.instance: # type: ignore
10
+ return wrapper.instance # type: ignore
11
+ wrapper.instance = cls(*args, **kwargs) # type: ignore
12
+ return wrapper.instance # type: ignore
13
+
14
+ wrapper.instance = None # type: ignore
15
+ return wrapper
@@ -0,0 +1,20 @@
1
+ import time
2
+ import logging
3
+ from functools import wraps
4
+
5
+
6
+ # Setup logger
7
+ logger = logging.getLogger(__name__)
8
+ logging.basicConfig(level=logging.INFO)
9
+
10
+
11
+ def timeit_log(func):
12
+ @wraps(func)
13
+ def wrapper(*args, **kwargs):
14
+ start = time.perf_counter()
15
+ result = func(*args, **kwargs)
16
+ duration = time.perf_counter() - start
17
+ logger.info(f"[{func.__name__}] executed in {duration:.4f} seconds")
18
+ return result
19
+
20
+ return wrapper
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: fificore
3
+ Version: 0.0.1
4
+ Summary: FiFi Core is full of tools
5
+ Author-email: FiFi <sayad.mehrdad@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 FiFi Sayad
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/fifisayad/FiFiCore.git
29
+ Keywords: core,db,utility
30
+ Classifier: Programming Language :: Python
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.12.0
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: SQLAlchemy
37
+ Provides-Extra: dev
38
+ Requires-Dist: black; extra == "dev"
39
+ Requires-Dist: bumpver; extra == "dev"
40
+ Requires-Dist: isort; extra == "dev"
41
+ Requires-Dist: pip-tools; extra == "dev"
42
+ Requires-Dist: pytest; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # FiFiCore
46
+ Repo consists of repeatative functionality across different projects which can use
47
+ this core library.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/fifi/__init__.py
5
+ src/fifi/database/engine_base.py
6
+ src/fifi/decorator/db_async_session_injection.py
7
+ src/fifi/decorator/singleton.py
8
+ src/fifi/decorator/time_log.py
9
+ src/fificore.egg-info/PKG-INFO
10
+ src/fificore.egg-info/SOURCES.txt
11
+ src/fificore.egg-info/dependency_links.txt
12
+ src/fificore.egg-info/requires.txt
13
+ src/fificore.egg-info/top_level.txt
@@ -0,0 +1,8 @@
1
+ SQLAlchemy
2
+
3
+ [dev]
4
+ black
5
+ bumpver
6
+ isort
7
+ pip-tools
8
+ pytest