Skip to main content

This repository is a collection of tools for developers to easily access relevant solutions for development in order to accelerate their workflow. It provides a variety of resources that are constantly used.

Project description

toolboxy

Status Maintainability PythonVersion Version Downloads

This repository is a collection of tools for developers. The goal is to offer a variety of resources that are constantly used, in order to accelerate the workflow. It is a way to quickly and easily access relevant solutions for development.

The functionality is diverse, some examples of code use are listed below. Feel free to suggest new functionality or directly contribute to the development of this repository.

cover

Language

The repository, as well as the docstrings of the functions, were developed with support for English and Brazilian Portuguese in order to facilitate access to functionality.

Table of Contents

Installation

To install, simply open the terminal and enter the following command:

pip install toolboxy

Usage

Web Scrapping

Convert header to Python dictionary
import toolboxy

headers = """sec-ch-ua-platform: "Windows"
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"""

headers_dict = toolboxy.chrome2dict(headers_str=headers)
Save source code in text file
import toolboxy

url = 'https://raw.githubusercontent.com/Lima-e-Silva/toolboxy/main/README.md'

toolboxy.html2txt(url=url, output_path='Github-toolboxy.txt')
Check if a given IP address and port can be used as a proxy
import toolboxy

# IP addresses and respective ports can be found here: "https://free-proxy-list.net"
ip = '80.252.5.34'
port = '7001'

if toolboxy.verify_proxy(ip=ip, port=port):
   print('IP and port are functional!')

Error Identification

Run a function with error logging
import toolboxy

# Function that is experiencing errors
def foo(a,b):
   return a/b

toolboxy.debug_function(foo, a=1, b=0, output='logfile')

File Manipulation

Create configuration file (cfg)
import toolboxy

config_dict = {
   'section': {
       'A': '1',
       'B': '2'
   }
}

toolboxy.create_cfg(file='config.cfg', cfg_dict=config_dict)
Read a configuration file (cfg)
import toolboxy

config_dict = toolboxy.read_cfg(file='config.cfg')
Create file backup
import toolboxy

toolboxy.backup(file='important_file.txt',
               output_path='backups/security_copies')
Verify file integrity or get hashes
import toolboxy

if toolboxy.check_hash('file.txt', 'backup.txt'):
   print('Integrity Verified')

file_hash = toolboxy.check_hash('file.txt')

Git Tools

Create a virtual environment
import toolboxy

toolboxy.create_env()
Create a license file
import toolboxy

toolboxy.license(license_type='MIT', name='Luiz Paulo Lima e Silva')
Generate a .gitignore file based on a standard template
import toolboxy

toolboxy.git_ignore(folders=['personal-folder'], extensions=['xlsx', 'pdf'])
Create requirements.txt
import toolboxy

toolboxy.requirements()

Windows Tools

Create Windows notification
import toolboxy

toolboxy.notify(
   id='toolboxy',
   title='Demonstration',
   message='This notification is merely a demonstration',
   buttons={'Open link': 'https://github.com/Lima-e-Silva/toolboxy/'},
   sound=True,
   audio_loop=False)
Schedule computer shutdown
import toolboxy

toolboxy.shutdown(time=3600, message="Time to sleep Zzz...")

Optimization

Generate function performance profile
import toolboxy

def foo(x, y=3):
   for n in range(x):
       print(n**y)

toolboxy.prof('output', foo, 100, y=2)
Calculate the elapsed time while running a function
import toolboxy

def foo(n):
   values = list()
   for i in range(n):
       for _ in range(i):
           values.append(i)
   print(values)

print(toolboxy.elapsed_clocktime(foo, 100))
Display the elapsed CPU time while running a function
import toolboxy

def foo(n):
   values = list()
   for i in range(n):
       for _ in range(i):
           values.append(i)
   print(values)

toolboxy.elapsed_cputime(foo, 100)

Miscellaneous

Displays strings in console with delay (like typing)
import toolboxy

toolboxy.delay_print('Hello World!')
Generates a docstring (according to the repository pattern) for a function
import toolboxy


def my_function():
   print("this is my function")


print(toolboxy.gpt_docstring(my_function,api_key="YOUR_API_KEY"))

# Output:
# """
# English:
# ----------
# Prints a string to the console.
#
# Returns
# -------
# None
#
# Português (brasileiro):
# ----------
# Imprime uma string no console.
#
# Retorna
# -------
# None
# """

# You can also store your api_key in a .env file then call the function without specifying the api_key.
# Example:
# toolboxy.gpt_docstring(my_function)
Generates a unique identification string
import toolboxy

id = toolboxy.unique_id(length=6,
                       letters=True,
                       numbers=True,
                       lower_case=False,
                       blocks=4)

# Example output: 0AMKPJ-LITCGF-N5A1LM-TCSHZF
Generate QR Code for a link
import toolboxy

toolboxy.QRcode(url='https://github.com/Lima-e-Silva/toolboxy/',
               size=150,
               output='My QR Code')

Free APIs

Create push notification (mobile)
import toolboxy

TOPIC = 'notifications'  # More information here: https://ntfy.sh

toolboxy.smartphone_notify(topic=TOPIC,
                          message='This is a demonstration notification',
                          title='Test Notification')
Shorten URL
import toolboxy

url = 'https://www.google.com.br'

if short:= toolboxy.short_url(url):
   print(short)

# Example Output: https://gotiny.cc/xr4cs6

Credits

Due to the nature of the repository, many of the implemented functions are full of dependencies. Therefore, it is essential to explicitly acknowledge the contribution of the community as a way of thanking them for the tools provided. Below is a list of the libraries and resources used and their respective licenses:

Library License
BeautifulSoup MIT
loguru MIT
openai MIT
ntfy Apache 2.0 - GPL 2.0
pipreqs Apache 2.0
pyperclip BSD-3-Clause
python-dotenv BSD-3-Clause
requests Apache 2.0
setuptools MIT
snakeviz License
winotify MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolboxy-0.1.2.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toolboxy-0.1.2-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file toolboxy-0.1.2.tar.gz.

File metadata

  • Download URL: toolboxy-0.1.2.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for toolboxy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b3816c6ba6340d7fbc56bc9ce352684f2ddfe29ae88a3a3a23062abc8e450f93
MD5 e2df47766cc67105a11a9c333ef04463
BLAKE2b-256 db3cc3c3b2019fa8cc70d56fa5c89c8e82aa65cbeca546074da14c61cb8fc898

See more details on using hashes here.

File details

Details for the file toolboxy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: toolboxy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for toolboxy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a6ec74077adbe0e2d13c02ae210fb475a33696590632a8f787615f8b2883cc1d
MD5 899e5415b65c7b3e9d73310d6ae131c6
BLAKE2b-256 eef8a252f0e09a5e2e2dd46e8bf2b05396ad0a64e694c288d99bcb8a9387a244

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page