Name | lazycon JSON |
Version |
0.6.4
JSON |
| download |
home_page | https://github.com/maxme1/lazycon |
Summary | Easy config files in pure Python |
upload_time | 2024-11-16 21:31:10 |
maintainer | None |
docs_url | None |
author | Max |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2017-2023 maxme1 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
config
lazy
interpreter
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![codecov](https://codecov.io/gh/maxme1/lazycon/branch/master/graph/badge.svg)](https://codecov.io/gh/maxme1/lazycon)
[![pypi](https://img.shields.io/pypi/v/lazycon?logo=pypi&label=PyPi)](https://pypi.org/project/lazycon/)
![License](https://img.shields.io/github/license/maxme1/lazycon)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/lazycon)](https://pypi.org/project/lazycon/)
![GitHub branch checks state](https://img.shields.io/github/checks-status/maxme1/lazycon/master)
Easy config files in pure Python!
What you can do directly in your configs:
- define constants
- define functions
- use import statements
- call functions and apply arithmetic operations
- a static read-only scope
- static checking: cycles detection, undefined variables detection
# Install
```shell
pip install lazycon
```
# Features
## Basic
Let's define a config file `example.config` and see what it can do
```python
# define constants
num_steps = 100
database_table = 'user_data'
# or more complex structures
parameters = {
'C': 10,
'metric': 'roc_auc',
}
values_to_try = [0, 1, 2, 3, 4]
# you can use and call builtins
some_range = list(range(100))
# or even comprehensions!
squares = [i ** 2 for i in range(20)]
```
Now let's load our config from python
```python
from lazycon import load
config = load('example.config')
print(config.database_table)
# 'user_data'
```
Need to change an existing config? No problem!
```python
from lazycon import load
config = load('example.config')
config.update(
database_table='customer_data',
some_range=[1, 3, 5],
)
config.dump('updated.config')
```
## Advanced
Python-based configs can do so much more! Let's create another `advanced.config`:
```python
# combine config entries
x = 1
y = 2
z = x + y
# define lambdas
callback = lambda value: 1 if value == 0 else (1 / value)
# or more complex functions
def strange_normalize(a, b):
temp = a ** 2 + b ** 2
return a / temp, b / temp
```
You can import from other python libraries:
```python
import numpy as np
from math import sqrt
const = np.pi / np.e
proportions = sqrt(2)
```
Or even other configs!
```python
# import from `example.config` defined above
from .example import *
extended_values_to_try = values_to_try + [101, 102]
```
# Contribute
Just get the project from GitHub and modify it how you please!
```shell
git clone https://github.com/maxme1/lazycon.git
cd lazycon
pip install -e .
```
Raw data
{
"_id": null,
"home_page": "https://github.com/maxme1/lazycon",
"name": "lazycon",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "config, lazy, interpreter",
"author": "Max",
"author_email": "Max <max@ira-labs.com>",
"download_url": "https://files.pythonhosted.org/packages/72/6c/4bc1d3bc42b3241617991c8618780d64ff003b926fae96016017649791c1/lazycon-0.6.4.tar.gz",
"platform": null,
"description": "[![codecov](https://codecov.io/gh/maxme1/lazycon/branch/master/graph/badge.svg)](https://codecov.io/gh/maxme1/lazycon)\n[![pypi](https://img.shields.io/pypi/v/lazycon?logo=pypi&label=PyPi)](https://pypi.org/project/lazycon/)\n![License](https://img.shields.io/github/license/maxme1/lazycon)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/lazycon)](https://pypi.org/project/lazycon/)\n![GitHub branch checks state](https://img.shields.io/github/checks-status/maxme1/lazycon/master)\n\nEasy config files in pure Python!\n\nWhat you can do directly in your configs:\n\n- define constants\n- define functions\n- use import statements\n- call functions and apply arithmetic operations\n- a static read-only scope\n- static checking: cycles detection, undefined variables detection\n\n# Install\n\n```shell\npip install lazycon\n```\n\n# Features\n\n## Basic\n\nLet's define a config file `example.config` and see what it can do\n\n```python\n# define constants\nnum_steps = 100\ndatabase_table = 'user_data'\n\n# or more complex structures\nparameters = {\n 'C': 10,\n 'metric': 'roc_auc',\n}\nvalues_to_try = [0, 1, 2, 3, 4]\n\n# you can use and call builtins\nsome_range = list(range(100))\n# or even comprehensions!\nsquares = [i ** 2 for i in range(20)]\n```\n\nNow let's load our config from python\n\n```python\nfrom lazycon import load\n\nconfig = load('example.config')\nprint(config.database_table)\n# 'user_data'\n```\n\nNeed to change an existing config? No problem!\n\n```python\nfrom lazycon import load\n\nconfig = load('example.config')\nconfig.update(\n database_table='customer_data',\n some_range=[1, 3, 5],\n)\nconfig.dump('updated.config')\n```\n\n## Advanced\n\nPython-based configs can do so much more! Let's create another `advanced.config`:\n\n```python\n# combine config entries\nx = 1\ny = 2\nz = x + y\n\n# define lambdas\ncallback = lambda value: 1 if value == 0 else (1 / value)\n\n\n# or more complex functions\ndef strange_normalize(a, b):\n temp = a ** 2 + b ** 2\n return a / temp, b / temp\n```\n\nYou can import from other python libraries:\n\n```python\nimport numpy as np\nfrom math import sqrt\n\nconst = np.pi / np.e\nproportions = sqrt(2)\n```\n\nOr even other configs!\n\n```python\n# import from `example.config` defined above\nfrom .example import *\n\nextended_values_to_try = values_to_try + [101, 102]\n```\n\n# Contribute\n\nJust get the project from GitHub and modify it how you please!\n\n```shell\ngit clone https://github.com/maxme1/lazycon.git\ncd lazycon\npip install -e .\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2017-2023 maxme1 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Easy config files in pure Python",
"version": "0.6.4",
"project_urls": {
"Bug Tracker": "https://github.com/maxme1/lazycon/issues",
"Download": "https://github.com/maxme1/lazycon/archive/v0.6.4.tar.gz",
"Homepage": "https://github.com/maxme1/lazycon",
"Source": "https://github.com/maxme1/lazycon"
},
"split_keywords": [
"config",
" lazy",
" interpreter"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "726c4bc1d3bc42b3241617991c8618780d64ff003b926fae96016017649791c1",
"md5": "42ffecbd034da270d0c8b2d56d5c99e0",
"sha256": "26e03608111c109922a74c45c802fd0d1d06604918028069139105416b8ab7c3"
},
"downloads": -1,
"filename": "lazycon-0.6.4.tar.gz",
"has_sig": false,
"md5_digest": "42ffecbd034da270d0c8b2d56d5c99e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 21999,
"upload_time": "2024-11-16T21:31:10",
"upload_time_iso_8601": "2024-11-16T21:31:10.235289Z",
"url": "https://files.pythonhosted.org/packages/72/6c/4bc1d3bc42b3241617991c8618780d64ff003b926fae96016017649791c1/lazycon-0.6.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-16 21:31:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maxme1",
"github_project": "lazycon",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "lazycon"
}