A core library for scalable Python applications
Project description
libcore-hng
A lightweight Python core package designed to unify access to diverse AI APIs and libraries. It provides a consistent, scalable foundation for building modular applications with clarity and flexibility.
アプリ初期処理サンプル
このプロジェクトでは、AppInitializer を用いてアプリケーションの初期化処理を行います。
初期化は一度だけ実行し、以降はグローバルインスタンス app_core を参照してください。
アプリ初期化方法
test_013_appinit.py
from libcore_hng.utils.app_core import AppInitializer
from test_013_config import DerivedConfig
class DerivedAppInitializer(AppInitializer[DerivedConfig]):
"""
AppInitializer拡張クラス
"""
def __init__(self, base_file: str = __file__, *config_file: str):
# 基底コンストラクタに拡張Configクラスを渡す
super().__init__(DerivedConfig, base_file, *config_file)
ins: DerivedAppInitializer | None = None
""" AppInitializer拡張クラスインスタンス """
def init_app(base_file: str = __file__, *config_file: str) -> DerivedAppInitializer:
"""
アプリケーション初期化
"""
global ins
ins = DerivedAppInitializer(base_file, *config_file)
return ins
test_013_config.py
from pydantic import BaseModel
from libcore_hng.core.base_config import BaseConfig
from libcore_hng.utils.app_logger_mixin import LoggingMixin
class Test(BaseModel, LoggingMixin):
"""
テスト設定クラスモデル
"""
append_member: str = "A"
""" 追加メンバー """
class DerivedConfig(BaseConfig):
"""
BaseConfig拡張クラス
"""
test: Test = Test()
""" テスト設定クラス """
@classmethod
def load_config(cls, base_file, *config_file) -> "DerivedConfig":
"""
BaseConfigのload_configをoverrride
戻り値の型は自身とする
"""
# 基底側のload_configを実行してjsonファイルを読み込む
base = super().load_config(base_file, *config_file)
# BaseConfigのインスタンスが持つ属性を取り出してDerivedConfigのインスタンスを返す
# **はキーワード引数に展開する構文(属性をclsに引数渡しする)
return cls(**base.__dict__)
test_013.py
import test_013_appinit as app
import test_013_sub as t013
# アプリ初期化(最初の一度だけ呼び出す)
app.init_app(__file__, "logger.json")
# 別ファイルのメソッド
t013.test013()
test_013_sub.py
import test_013_appinit as app
def test013():
# 拡張Configクラスのメンバーをprint
print(app.ins.config.test.append_member)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libcore_hng-2.0.19.tar.gz.
File metadata
- Download URL: libcore_hng-2.0.19.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86d29b713d3e501cfa90fb05b565e02254f0b7547108a676edcdfc9d6534292f
|
|
| MD5 |
a64397744977617e5b41b2fa9f940921
|
|
| BLAKE2b-256 |
d6a64eac8938aa807fe6634e6ad0558b111891725ed0130b9969dcba8389ee5c
|
Provenance
The following attestation bundles were made for libcore_hng-2.0.19.tar.gz:
Publisher:
release.yml on kaioman/libcore-hng
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libcore_hng-2.0.19.tar.gz -
Subject digest:
86d29b713d3e501cfa90fb05b565e02254f0b7547108a676edcdfc9d6534292f - Sigstore transparency entry: 850189404
- Sigstore integration time:
-
Permalink:
kaioman/libcore-hng@9572ff4127c8acafd158914fa6c32a4acce0c9b7 -
Branch / Tag:
refs/tags/v2.0.19 - Owner: https://github.com/kaioman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9572ff4127c8acafd158914fa6c32a4acce0c9b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file libcore_hng-2.0.19-py3-none-any.whl.
File metadata
- Download URL: libcore_hng-2.0.19-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
525ad116d53ef96702e65072ffacd694897db34386dc37fb073900ed593e3b06
|
|
| MD5 |
15a87df565c1dacfc00801a47868b644
|
|
| BLAKE2b-256 |
2956d7cfacc8af6494da005a03b90c9798f4220100c4949783b42f9a934315f0
|
Provenance
The following attestation bundles were made for libcore_hng-2.0.19-py3-none-any.whl:
Publisher:
release.yml on kaioman/libcore-hng
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libcore_hng-2.0.19-py3-none-any.whl -
Subject digest:
525ad116d53ef96702e65072ffacd694897db34386dc37fb073900ed593e3b06 - Sigstore transparency entry: 850189409
- Sigstore integration time:
-
Permalink:
kaioman/libcore-hng@9572ff4127c8acafd158914fa6c32a4acce0c9b7 -
Branch / Tag:
refs/tags/v2.0.19 - Owner: https://github.com/kaioman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9572ff4127c8acafd158914fa6c32a4acce0c9b7 -
Trigger Event:
push
-
Statement type: