A library to share some common methods and helpers in projects.
|
|
||
|---|---|---|
| .devcontainer | ||
| .github | ||
| .vscode | ||
| examples | ||
| inetsix_helpers | ||
| tests | ||
| .drone.yml | ||
| .editorconfig | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| codecov.yaml | ||
| CONTRIBUTING.md | ||
| Dockerfile | ||
| LICENCE | ||
| pyproject.toml | ||
| README.md | ||
Inetsix Helpers Python Library
Description
inetsix-helpers is a Python library designed to share common methods and helpers in projects. It facilitates project development by providing custom types, filters, and search functions.
Usage Example
Search for a value in a nested dictionary
from inetsix_helpers.lookup import get_value_from_nested_dict
# Example dictionary
dictionary = {
"vlan": {
"id": 10,
"name": "VLAN10",
"description": "This is VLAN 10"
},
"hostname": "example.com"
}
# Use the get_value_from_nested_dict function
vlan_id = get_value_from_nested_dict(dictionary, "vlan.id", required=True)
hostname = get_value_from_nested_dict(dictionary, "hostname", required=True)
print(vlan_id) # The output will be 10
print(hostname) # The output will be 'example.com'
Compress a list of VLANs
from inetsix_helpers.filters import list_compress
# VLAN list
vlan_list = list(range(10, 18))
# Use the list_compress function
compressed_vlan_list = list_compress(vlan_list)
print(compressed_vlan_list) # The output will be '10-17'
Installation
Installation with Pip
pip install git+https://git.as73.inetsix.net/tom/python-helpers.git
Installation with Git
# Clone repository
git clone git@git.as73.inetsix.net:tom/python-helpers.git
# Move to repository folder
cd python-helpers
# Install project using pip
pip install .
Usage
After installation, you can import the inetsix-helpers modules into your Python code.
from inetsix_helpers import custom_types, filters, lookup
...
Contribution
Please read contribution guide for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for more details.