[![License: GNU GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/ashfaque/ashfaquecodes/blob/main/LICENSE)
## How to install
```sh
pip install ashfaquecodes
```
## Documentation
- Color the printed outputs in terminal.
```python
from ashfaquecodes.ashfaquecodes import (
, blue_print_start
, red_print_start
, green_print_start
, color_print_reset
)
import pprint
pp = pprint.PrettyPrinter(indent=4)
# blue_print_start()
red_print_start()
# green_print_start()
pp.pprint("--------------------------")
color_print_reset()
```
- Get a unique list if list of non-unique elements passed in this function.
```python
from ashfaquecodes.ashfaquecodes import unique_list
_ = unique_list(non_unique_list)
```
- Get unique list of dictionaries if a list of duplicate dictionaries passed in this function.
```python
from ashfaquecodes.ashfaquecodes import unique_list_of_dicts
_ = unique_list_of_dicts(non_unique_list_of_dicts)
```
- Get a list of non-empty dictionaries if a list of empty and non-empty dictionaries passed in this function.
```python
from ashfaquecodes.ashfaquecodes import remove_empty_dicts_from_list
_ = remove_empty_dicts_from_list(list_with_empty_dicts)
```
- Get a sorted list of dictionaries returned according to your desired sorting key of the dictionary if a list of non-empty dictionaries passed in this function. Supports ascending and descending order.
```python
from ashfaquecodes.ashfaquecodes import sort_list_of_dicts
_ = sort_list_of_dicts(unsorted_list = unsorted_lst, key = 'dict_key_name', desc = True)
```
- Get execution time of your code. Can also prints the execution time in terminal if an optional parameter `print_time = True` is passed in the function.
```python
from ashfaquecodes.ashfaquecodes import (
get_execution_start_time
, get_execution_end_time
)
execution_start_time = get_execution_start_time()
total_execution_time_str = get_execution_end_time(execution_start_time, print_time = True)
```
- Custom Decorator to calculate execution time of a function which will be printed in the terminal during execution of that function.
```python
from ashfaquecodes.ashfaquecodes import timer
@timer
def your_function(request):
pass
```
- Custom `cprint()` function to print output in the terminal with different colors.
```python
from ashfaquecodes.ashfaquecodes import cprint
cprint('This is ' + 'a' + ' test print statement', color='red')
cprint('This is an error message', color='green')
cprint("Python : %2d, Portal : %5.2f" % (1, 05.333), color='yellow')
cprint("Total students : %3d, Boys : %2d" % (240, 120), color='blue')
cprint("%7.3o" % (25), color='magenta')
cprint("%10.3E" % (356.08977), color='cyan')
cprint('I love "{}!"'.format('Python'), color='white')
cprint(f"I love {'Python'} \"{'Language'}!\"", color='red')
data = dict(fun ="Python", adj ="Portal")
cprint("I love {fun} computer {adj}".format(**data), color='red')
cstr = "I love Python"
# Printing the center aligned string with fillchr
cprint("Center aligned string with fillchr: ", color='green')
cprint(cstr.center(40, '#'), color='yellow')
# cprinting the left aligned string with "-" padding
cprint("The left aligned string is : ", color='blue')
cprint(cstr.ljust(40, '-'), color='magenta')
# cprinting the right aligned string with "-" padding
cprint("The right aligned string is : ", color='cyan')
cprint(cstr.rjust(40, '-'), color='white')
```
- Custom `cpprint` function to pprint output in the terminal with different colors and different formats.
```python
from ashfaquecodes.ashfaquecodes import cpprint
sample_data = {
'key5': 'value1',
'key2': 'value2',
'key3': {
'nested_key': 'nested_value',
'nested_dict': {
'deep_key': 'deep_value'
}
},
'key4': [1, 2, 3, 4, 5],
'key1': [
{'name': 'John', 'age': 30},
{'name': 'Alice', 'age': 25},
{'name': 'Bob', 'age': 35}
]
}
cpprint(sample_data, indent = 4, color='green', width=80, depth=2, compact=False, sort_dicts=True)
# Available colors: ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
```
- Query a large list of dicts like any SQL WHERE clause.
```python
from ashfaquecodes.ashfaquecodes import query_list_of_dicts
data = [
{'age': 23, 'name': 'user11'},
{'age': 27, 'name': 'user12'},
{'age': 25, 'name': 'user13'}
]
# Using the 'sqlite' engine (default)
query_conditions = "age > 25 OR name LIKE '%user11%'"
filtered_data = query_list_of_dicts(input_list_of_dicts, query_conditions)
# Using the 'pandas' engine (pandas needs to be installed to use this)
query_conditions = 'age == 25 or name.str.contains("user11")'
filtered_data = query_list_of_dicts(input_list_of_dicts, query_conditions, engine='pandas')
```
## License
[GNU GPLv3](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/ashfaque/ashfaquecodes",
"name": "ashfaquecodes",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "ASHFAQUE, ASHFAQUECODES, PRODUCTIVITY",
"author": "Ashfaque Alam",
"author_email": "ashfaquealam496@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/fa/66/407725e8f4c257c7071560e2dc610a7fee997aa7178680a0c13f1e6bbaf0/ashfaquecodes-0.8.tar.gz",
"platform": null,
"description": "[![License: GNU GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/ashfaque/ashfaquecodes/blob/main/LICENSE)\r\n\r\n## How to install\r\n```sh\r\npip install ashfaquecodes\r\n```\r\n\r\n## Documentation\r\n- Color the printed outputs in terminal.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import (\r\n , blue_print_start\r\n , red_print_start\r\n , green_print_start\r\n , color_print_reset\r\n )\r\n import pprint\r\n pp = pprint.PrettyPrinter(indent=4)\r\n # blue_print_start()\r\n red_print_start()\r\n # green_print_start()\r\n pp.pprint(\"--------------------------\")\r\n color_print_reset()\r\n ```\r\n\r\n- Get a unique list if list of non-unique elements passed in this function.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import unique_list\r\n _ = unique_list(non_unique_list)\r\n ```\r\n\r\n- Get unique list of dictionaries if a list of duplicate dictionaries passed in this function.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import unique_list_of_dicts\r\n _ = unique_list_of_dicts(non_unique_list_of_dicts)\r\n ```\r\n\r\n- Get a list of non-empty dictionaries if a list of empty and non-empty dictionaries passed in this function.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import remove_empty_dicts_from_list\r\n _ = remove_empty_dicts_from_list(list_with_empty_dicts)\r\n ```\r\n\r\n- Get a sorted list of dictionaries returned according to your desired sorting key of the dictionary if a list of non-empty dictionaries passed in this function. Supports ascending and descending order.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import sort_list_of_dicts\r\n _ = sort_list_of_dicts(unsorted_list = unsorted_lst, key = 'dict_key_name', desc = True)\r\n ```\r\n\r\n- Get execution time of your code. Can also prints the execution time in terminal if an optional parameter `print_time = True` is passed in the function.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import (\r\n get_execution_start_time\r\n , get_execution_end_time\r\n )\r\n execution_start_time = get_execution_start_time()\r\n total_execution_time_str = get_execution_end_time(execution_start_time, print_time = True)\r\n ```\r\n\r\n- Custom Decorator to calculate execution time of a function which will be printed in the terminal during execution of that function.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import timer\r\n @timer\r\n def your_function(request):\r\n pass\r\n ```\r\n\r\n- Custom `cprint()` function to print output in the terminal with different colors.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import cprint\r\n\r\n cprint('This is ' + 'a' + ' test print statement', color='red')\r\n cprint('This is an error message', color='green')\r\n cprint(\"Python : %2d, Portal : %5.2f\" % (1, 05.333), color='yellow')\r\n cprint(\"Total students : %3d, Boys : %2d\" % (240, 120), color='blue')\r\n cprint(\"%7.3o\" % (25), color='magenta')\r\n cprint(\"%10.3E\" % (356.08977), color='cyan')\r\n cprint('I love \"{}!\"'.format('Python'), color='white')\r\n cprint(f\"I love {'Python'} \\\"{'Language'}!\\\"\", color='red')\r\n\r\n data = dict(fun =\"Python\", adj =\"Portal\")\r\n cprint(\"I love {fun} computer {adj}\".format(**data), color='red')\r\n\r\n cstr = \"I love Python\"\r\n # Printing the center aligned string with fillchr\r\n cprint(\"Center aligned string with fillchr: \", color='green')\r\n cprint(cstr.center(40, '#'), color='yellow')\r\n\r\n # cprinting the left aligned string with \"-\" padding\r\n cprint(\"The left aligned string is : \", color='blue')\r\n cprint(cstr.ljust(40, '-'), color='magenta')\r\n\r\n # cprinting the right aligned string with \"-\" padding\r\n cprint(\"The right aligned string is : \", color='cyan')\r\n cprint(cstr.rjust(40, '-'), color='white')\r\n ```\r\n\r\n- Custom `cpprint` function to pprint output in the terminal with different colors and different formats.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import cpprint\r\n\r\n sample_data = {\r\n 'key5': 'value1',\r\n 'key2': 'value2',\r\n 'key3': {\r\n 'nested_key': 'nested_value',\r\n 'nested_dict': {\r\n 'deep_key': 'deep_value'\r\n }\r\n },\r\n 'key4': [1, 2, 3, 4, 5],\r\n 'key1': [\r\n {'name': 'John', 'age': 30},\r\n {'name': 'Alice', 'age': 25},\r\n {'name': 'Bob', 'age': 35}\r\n ]\r\n }\r\n\r\n cpprint(sample_data, indent = 4, color='green', width=80, depth=2, compact=False, sort_dicts=True)\r\n # Available colors: ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']\r\n ```\r\n\r\n- Query a large list of dicts like any SQL WHERE clause.\r\n ```python\r\n from ashfaquecodes.ashfaquecodes import query_list_of_dicts\r\n\r\n data = [\r\n {'age': 23, 'name': 'user11'},\r\n {'age': 27, 'name': 'user12'},\r\n {'age': 25, 'name': 'user13'}\r\n ]\r\n\r\n # Using the 'sqlite' engine (default)\r\n query_conditions = \"age > 25 OR name LIKE '%user11%'\"\r\n filtered_data = query_list_of_dicts(input_list_of_dicts, query_conditions)\r\n\r\n # Using the 'pandas' engine (pandas needs to be installed to use this)\r\n query_conditions = 'age == 25 or name.str.contains(\"user11\")'\r\n filtered_data = query_list_of_dicts(input_list_of_dicts, query_conditions, engine='pandas')\r\n ```\r\n\r\n\r\n\r\n## License\r\n[GNU GPLv3](LICENSE)\r\n\r\n",
"bugtrack_url": null,
"license": "GNU GPLv3",
"summary": "Codes which can be used to increase productivity.",
"version": "0.8",
"project_urls": {
"Download": "https://github.com/ashfaque/ashfaquecodes/archive/refs/tags/v_08.tar.gz",
"Homepage": "https://github.com/ashfaque/ashfaquecodes"
},
"split_keywords": [
"ashfaque",
" ashfaquecodes",
" productivity"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fa66407725e8f4c257c7071560e2dc610a7fee997aa7178680a0c13f1e6bbaf0",
"md5": "67a03fa3c367692304d94cc62bd969ae",
"sha256": "b18bcc36fe825de5fec4d04b6aeacc7282b57c4c0852b2888666462179956d1b"
},
"downloads": -1,
"filename": "ashfaquecodes-0.8.tar.gz",
"has_sig": false,
"md5_digest": "67a03fa3c367692304d94cc62bd969ae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21553,
"upload_time": "2024-05-05T16:14:14",
"upload_time_iso_8601": "2024-05-05T16:14:14.091547Z",
"url": "https://files.pythonhosted.org/packages/fa/66/407725e8f4c257c7071560e2dc610a7fee997aa7178680a0c13f1e6bbaf0/ashfaquecodes-0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-05 16:14:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ashfaque",
"github_project": "ashfaquecodes",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ashfaquecodes"
}