loe-simp-app-fw


Nameloe-simp-app-fw JSON
Version 2.10.10 PyPI version JSON
download
home_pageNone
SummaryA super simple python app framework that includes a logger and a config manager. Also usable in jupyter notebook.
upload_time2024-08-28 06:00:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords framework logger config mangager
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # loe-simp-app-fw

A super simple python app framework that includes a logger and a config manager. This framework is also useable in Jupyter Notebook.

In addition to those function, it has a CSV IO object, a Caching object to help with common data tasks.

## Example

To get started, 

```bash
python3 -m loe_simp_app_fw init-repo
```

It will generate a project structure,

```
project directory
├── .gitignore
├── .cache
│   └── (Hashed file name)
├── config-framework.yaml
├── config-project.yaml
├── LICENSE
├── log
│   └── 2024-04-16.log
├── README.md
└── src
    ├── configuration.py
    └── main.py

```

## What happens after init

In `configuration.py`, after the initialization, it would be,

```python
import os

from typing import ClassVar
from loe_simp_app_fw import BaseConfig, FrameworkConfig, Logger, NotInitialized, CacheManager

#---------------------------------------------------------------

# Modify the framework config location if necessary
FrameworkConfig.load(os.path.abspath("./config-framework.yaml"))


class ProjectConfig(BaseConfig):
    # Add tunable here
    example_tunable: ClassVar[str] = "ExAmPlE"

#---------------------------------------------------------------

if FrameworkConfig.developer_mode:
    # Skip loading the config
    '''
    Developer mode force the usage of the default configuration of ProjectConfig,
        i.e., the one above, rather than the one in config-project.yaml
    '''
    Logger.warning(f"Project config is now in developer mode, settings from config-project.yaml will be ignored")
else:
    # Load the config
    try:
        ProjectConfig.load(FrameworkConfig.project_config_path)
    except NotInitialized:
        Logger.warning(f"Cannot find project config file at {FrameworkConfig.project_config_path}.")
        ProjectConfig.dump_example(FrameworkConfig.project_config_path)
        Logger.info(f"Successfully create example project config at {FrameworkConfig.project_config_path}")

# Combine two config
class Config(ProjectConfig, FrameworkConfig):
    pass

# Init logger
Logger.bootstrap(Config.log_directory, log_level = Config.log_level, buffering = Config.log_buffer_size)

# Init Cache Manager
CacheManager.setup(Config.cache_directory, Config.cache_time_to_live)

Logger.info("Configuration finish initialization")
```

One may add additional tunables under ProjectConfig as a class variable.

In `main.py`, after the initialization, it would be

```python
from loe_simp_app_fw import Logger
from configuration import Config

```

## Basic Usage

### Logger usage

```python
from loe_simp_app_fw import Logger

Logger.debug("This is a debug message.")
Logger.info("This is a info message.")
Logger.warning("This is a warning message.")
Logger.error("This is a error message.")
```

### Config usage

```python
from configuration import Config

something = Config.log_level
```

### Additional tools

```python
from loe_simp_app_fw import isNotebook

# Return True when in a jupyter notebook environment

```

## .gitignore

`.gitignore` file will be generated for the project.

In addition to the python gitignore template from GitHub, the following are also added.

```.gitignore
# Loe's Simple App Framework
playground*
database*
config*.yaml
raw
middleware
.cache*
perf/
temp
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "loe-simp-app-fw",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "framework, logger, config mangager",
    "author": null,
    "author_email": "loeeeee <95266635+loeeeee@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/f7/20/aae72c7361566626ebee796370068b74d9de8de138d5a690eee5023a6cd9/loe_simp_app_fw-2.10.10.tar.gz",
    "platform": null,
    "description": "# loe-simp-app-fw\n\nA super simple python app framework that includes a logger and a config manager. This framework is also useable in Jupyter Notebook.\n\nIn addition to those function, it has a CSV IO object, a Caching object to help with common data tasks.\n\n## Example\n\nTo get started, \n\n```bash\npython3 -m loe_simp_app_fw init-repo\n```\n\nIt will generate a project structure,\n\n```\nproject directory\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 .cache\n\u2502   \u2514\u2500\u2500 (Hashed file name)\n\u251c\u2500\u2500 config-framework.yaml\n\u251c\u2500\u2500 config-project.yaml\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 log\n\u2502   \u2514\u2500\u2500 2024-04-16.log\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 src\n    \u251c\u2500\u2500 configuration.py\n    \u2514\u2500\u2500 main.py\n\n```\n\n## What happens after init\n\nIn `configuration.py`, after the initialization, it would be,\n\n```python\nimport os\n\nfrom typing import ClassVar\nfrom loe_simp_app_fw import BaseConfig, FrameworkConfig, Logger, NotInitialized, CacheManager\n\n#---------------------------------------------------------------\n\n# Modify the framework config location if necessary\nFrameworkConfig.load(os.path.abspath(\"./config-framework.yaml\"))\n\n\nclass ProjectConfig(BaseConfig):\n    # Add tunable here\n    example_tunable: ClassVar[str] = \"ExAmPlE\"\n\n#---------------------------------------------------------------\n\nif FrameworkConfig.developer_mode:\n    # Skip loading the config\n    '''\n    Developer mode force the usage of the default configuration of ProjectConfig,\n        i.e., the one above, rather than the one in config-project.yaml\n    '''\n    Logger.warning(f\"Project config is now in developer mode, settings from config-project.yaml will be ignored\")\nelse:\n    # Load the config\n    try:\n        ProjectConfig.load(FrameworkConfig.project_config_path)\n    except NotInitialized:\n        Logger.warning(f\"Cannot find project config file at {FrameworkConfig.project_config_path}.\")\n        ProjectConfig.dump_example(FrameworkConfig.project_config_path)\n        Logger.info(f\"Successfully create example project config at {FrameworkConfig.project_config_path}\")\n\n# Combine two config\nclass Config(ProjectConfig, FrameworkConfig):\n    pass\n\n# Init logger\nLogger.bootstrap(Config.log_directory, log_level = Config.log_level, buffering = Config.log_buffer_size)\n\n# Init Cache Manager\nCacheManager.setup(Config.cache_directory, Config.cache_time_to_live)\n\nLogger.info(\"Configuration finish initialization\")\n```\n\nOne may add additional tunables under ProjectConfig as a class variable.\n\nIn `main.py`, after the initialization, it would be\n\n```python\nfrom loe_simp_app_fw import Logger\nfrom configuration import Config\n\n```\n\n## Basic Usage\n\n### Logger usage\n\n```python\nfrom loe_simp_app_fw import Logger\n\nLogger.debug(\"This is a debug message.\")\nLogger.info(\"This is a info message.\")\nLogger.warning(\"This is a warning message.\")\nLogger.error(\"This is a error message.\")\n```\n\n### Config usage\n\n```python\nfrom configuration import Config\n\nsomething = Config.log_level\n```\n\n### Additional tools\n\n```python\nfrom loe_simp_app_fw import isNotebook\n\n# Return True when in a jupyter notebook environment\n\n```\n\n## .gitignore\n\n`.gitignore` file will be generated for the project.\n\nIn addition to the python gitignore template from GitHub, the following are also added.\n\n```.gitignore\n# Loe's Simple App Framework\nplayground*\ndatabase*\nconfig*.yaml\nraw\nmiddleware\n.cache*\nperf/\ntemp\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A super simple python app framework that includes a logger and a config manager. Also usable in jupyter notebook.",
    "version": "2.10.10",
    "project_urls": {
        "Homepage": "https://github.com/loeeeee/loe-simp-app-fw",
        "Issues": "https://github.com/loeeeee/loe-simp-app-fw/issues"
    },
    "split_keywords": [
        "framework",
        " logger",
        " config mangager"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e777855f2d7ad99059e750f1e93e42e2f35b943e234ba513e9d2d22b18cbc183",
                "md5": "37622fc6b4655a4db9279538b8192f72",
                "sha256": "857bcca7207b47541606cfeabcc1b236e08415ae110b3bbfe3b8d3082f30b769"
            },
            "downloads": -1,
            "filename": "loe_simp_app_fw-2.10.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37622fc6b4655a4db9279538b8192f72",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 44423,
            "upload_time": "2024-08-28T06:00:44",
            "upload_time_iso_8601": "2024-08-28T06:00:44.241325Z",
            "url": "https://files.pythonhosted.org/packages/e7/77/855f2d7ad99059e750f1e93e42e2f35b943e234ba513e9d2d22b18cbc183/loe_simp_app_fw-2.10.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f720aae72c7361566626ebee796370068b74d9de8de138d5a690eee5023a6cd9",
                "md5": "39092023ff936496444c7867713b4669",
                "sha256": "fff34fa3f3a175823d8816ee6fc3f7cccce28b6bb3ba5ca0b00fe918f4b1395f"
            },
            "downloads": -1,
            "filename": "loe_simp_app_fw-2.10.10.tar.gz",
            "has_sig": false,
            "md5_digest": "39092023ff936496444c7867713b4669",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 36202,
            "upload_time": "2024-08-28T06:00:46",
            "upload_time_iso_8601": "2024-08-28T06:00:46.071099Z",
            "url": "https://files.pythonhosted.org/packages/f7/20/aae72c7361566626ebee796370068b74d9de8de138d5a690eee5023a6cd9/loe_simp_app_fw-2.10.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-28 06:00:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "loeeeee",
    "github_project": "loe-simp-app-fw",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "loe-simp-app-fw"
}
        
Elapsed time: 0.32316s