webdevkits 0.0.9
A package for web dev which is base on sqlalchemy and flask.
License: MIT
Requires Python: >=3.6

# Web Develop Kits
<a href="https://www.buymeacoffee.com/ronchang" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" align="right"></a>
`python_requires>=3.6`

# dbkits
##

### Utils

#### `snake2camel` and `camel2snake`
> snake_case and CamelCase Converter, round way to convert style string

```python
from dbkits import Utils
result = Utils.snake2camel('my_model_name')
# result:
# MyModelName
```

```python
from dbkits import Utils
result = Utils.camel2snake('MyModelName')
# result:
# 'my_model_name'
```
---

## Slicer

#### `split_list`, `split_dict` and `split_number`
> Tow different ways to split a container or a number.

#### 1. How to use "split_list"
*`Note: "slice_length" or "container_length" is a control number either one of them is necessary`*

```python
from webdevkits import Slicer

Slicer.split_list(
    input_data,  # targets, required a list
    slice_length=None,  # setting to make every slice as this number.
    container_length=None,  # setting to be trying to lean on as a container number.
    recurs=True  # dimension reduce as one dimension
)
```

#### 2. How to use "split_dict"

```python
from webdevkits import Slicer

Slicer.split_dict(
    input_data,  # targets, required a dict
    slice_length=None,  # setting to make every slice as this number.
    container_length=None,  # setting to be trying to lean on as a container number.
)
```

#### 3. How to use "split_number"

```python
from webdevkits import Slicer

Slicer.split_number(
    number,  # targets, required a number
    slice_length=None,  # setting to make every slice as this number.
    container_length=None,  # setting to be trying to lean on as a container number.
)
```

```python
Slicer.split_list([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], slice_length=3)
# result:
# [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
```

```python
ContainerKnife.split_list([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], slice_length=3)
# result:
# [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
```

```python
ContainerKnife.split_list([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], container_length=3)
# result:
# [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
```

#### Demo
```python
from dbkits import Slicer

def demo(**kwargs):
    if 'input_data' in kwargs and isinstance(kwargs['input_data'], list):
        method = getattr(Slicer, 'split_list')
        src = kwargs['input_data']
    elif 'input_data' in kwargs and isinstance(kwargs['input_data'], dict):
        method = getattr(Slicer, 'split_dict')
        src = kwargs['input_data']
    elif 'number' in kwargs and type(kwargs['number']) in [str, int]:
        method = getattr(Slicer, 'split_number')
        src = kwargs['number']
    else:
        raise ValueError(f'Invalid type or error input! {kwargs}')
    results = method(**kwargs)
    print(f'{"":=^90}')
    print(f'Input:\n\t{src}')
    print(f'Results:\n\t{results}')
    print(f'Amount: {len(results)}')
    print(f'{"":-^90}')
    for index, result in enumerate(results):
        print(f'slice {index} | len == {len(result)} | {result}')
    print(f'{"":=^90}')

## ################## Demo a: split list  ################## ##
demo(input_data=[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], slice_length=4)

## ################## Demo b: split dict  ################## ##
input_data = {
    '1': {'name': 'Ajax', 'age': 25},
    '2': {'name': 'Roni', 'age': 29},
    '3': {'name': 'Jeffrey', 'age': 34},
    '4': {'name': 'Josh', 'age': 33},
    '5': {'name': 'Kevin', 'age': 26},
    '6': {'name': 'Jeque', 'age': 23},
    '7': {'name': 'Amy', 'age': 32},
    '8': {'name': 'May', 'age': 49},
    '9': {'name': 'Ronnie', 'age': 22},
}
demo(input_data=input_data, slice_length=2)

## ################## Demo c: split a number ################## ##
demo(number=40, slice_length=7)
```

---
## 1. Model Extractor
>Aim to slice cache out models to the python container(list and dict)