From adee254366bf8134b13167ad559151dfa69e12c3 Mon Sep 17 00:00:00 2001 From: shadowy-pycoder <35629483+shadowy-pycoder@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:10:02 +0300 Subject: [PATCH] Fixed README.md, bumped to v0.1.2 --- README.md | 8 ++++---- pyproject.toml | 2 +- pyya.egg-info/PKG-INFO | 10 +++++----- pyya/__init__.py | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d656dd1..8022e7c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# paya - Simple tool that converts YAML configuration files to Python objects +# pyya - Simple tool that converts YAML configuration files to Python objects ![PyPI - Downloads](https://img.shields.io/pypi/dd/pyya) [![ClickPy Dashboard](https://img.shields.io/badge/clickpy-dashboard-orange)](https://clickpy.clickhouse.com/dashboard/pyya) @@ -12,7 +12,7 @@ - Very `lightweight` and `simple` API (currently it contains only one function) - `Easy` to use -- Based on popular and well-tested libraries (like `camel-converter` and `munch`) +- Based on popular and well-tested libraries (like `camel-converter`, `PyYAML` and `munch`) - Automatically `merge` default and production configuration files - Convert keys in configuration files to `snake_case` @@ -64,9 +64,9 @@ print(json.dumps(config.database)) As you can see, `pyya` automatically merges default config file with production config file. -Under the hood `pyya` uses [munch](https://pypi.org/project/munch/) library to create attribute-stylish dictionaries. +Under the hood `pyya` uses [PyYAML](https://pypi.org/project/PyYAML/) to parse YAML files and [munch](https://pypi.org/project/munch/) library to create attribute-stylish dictionaries. -`paya` automatically adds underscore prefix to Python keywords and can be configured to convert `camelCase` or `PascalCase` keys to `snake_case`. +`pyya` automatically adds underscore prefix to Python keywords and can be configured to convert `camelCase` or `PascalCase` keys to `snake_case`. If `raise_error_non_identifiers=True`, `pyya` will raise error if section name is not valid Python identifier. diff --git a/pyproject.toml b/pyproject.toml index 47bfea3..f5f4e9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyya" -version = "0.1.1" +version = "0.1.2" authors = [ { name="shadowy-pycoder", email="shadowy-pycoder@example.com" }, ] diff --git a/pyya.egg-info/PKG-INFO b/pyya.egg-info/PKG-INFO index b2c16cd..179c3fb 100644 --- a/pyya.egg-info/PKG-INFO +++ b/pyya.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pyya -Version: 0.1.1 +Version: 0.1.2 Summary: Convert YAML configuration files to Python objects Author-email: shadowy-pycoder Project-URL: Homepage, https://github.com/shadowy-pycoder/pyya @@ -24,7 +24,7 @@ Requires-Dist: munch>=4.0.0 Requires-Dist: pyyaml>=6.0.2 Requires-Dist: types-pyyaml>=6.0.12.20240917 -# paya - Simple tool that converts YAML configuration files to Python objects +# pyya - Simple tool that converts YAML configuration files to Python objects ![PyPI - Downloads](https://img.shields.io/pypi/dd/pyya) [![ClickPy Dashboard](https://img.shields.io/badge/clickpy-dashboard-orange)](https://clickpy.clickhouse.com/dashboard/pyya) @@ -38,7 +38,7 @@ Requires-Dist: types-pyyaml>=6.0.12.20240917 - Very `lightweight` and `simple` API (currently it contains only one function) - `Easy` to use -- Based on popular and well-tested libraries (like `camel-converter` and `munch`) +- Based on popular and well-tested libraries (like `camel-converter`, `PyYAML` and `munch`) - Automatically `merge` default and production configuration files - Convert keys in configuration files to `snake_case` @@ -90,9 +90,9 @@ print(json.dumps(config.database)) As you can see, `pyya` automatically merges default config file with production config file. -Under the hood `pyya` uses [munch](https://pypi.org/project/munch/) library to create attribute-stylish dictionaries. +Under the hood `pyya` uses [PyYAML](https://pypi.org/project/PyYAML/) to parse YAML files and [munch](https://pypi.org/project/munch/) library to create attribute-stylish dictionaries. -`paya` automatically adds underscore prefix to Python keywords and can be configured to convert `camelCase` or `PascalCase` keys to `snake_case`. +`pyya` automatically adds underscore prefix to Python keywords and can be configured to convert `camelCase` or `PascalCase` keys to `snake_case`. If `raise_error_non_identifiers=True`, `pyya` will raise error if section name is not valid Python identifier. diff --git a/pyya/__init__.py b/pyya/__init__.py index a1e0809..ab6669a 100644 --- a/pyya/__init__.py +++ b/pyya/__init__.py @@ -9,13 +9,13 @@ logging.basicConfig(format='%(asctime)-15s \t%(levelname)-8s \t%(name)-8s \t%(message)s') -logger = logging.getLogger('paya') +logger = logging.getLogger(__name__) ConfigType = Dict[str, Any] -class PayaError(RuntimeError): ... +class PyyaError(RuntimeError): ... def init_config( @@ -42,7 +42,7 @@ def _sanitize_section(section: str) -> str: if raise_error_non_identifiers and not section.isidentifier(): err_msg = f'section `{section}` is not a valid identifier, aborting' logger.error(err_msg) - raise PayaError(err_msg) + raise PyyaError(err_msg) if keyword.iskeyword(section): logger.warning(f'section `{section}` is a keyword, renaming to `_{section}`') section = f'_{section}' @@ -55,7 +55,7 @@ def _sanitize_section(section: str) -> str: raise FileNotFoundError() except FileNotFoundError as e: logger.error(e) - raise PayaError(f'{default_config} file is missing or empty') from None + raise PyyaError(f'{default_config} file is missing or empty') from None try: with open(Path(config)) as fstream: _raw_data: ConfigType = yaml.safe_load(fstream) or {} @@ -68,4 +68,4 @@ def _sanitize_section(section: str) -> str: except Exception as e: message = f'{default_config} file is corrupted: {repr(e)}' logger.error(message) - raise PayaError(message) from None + raise PyyaError(message) from None