Skip to main content

Useful tools for every project.

Project description

KdnTools

Description

KdnTools is a Python package that provides a collection of useful tools for common tasks in Python development. Whether you"re working with databases, handling user interactions, or performing various operations, KdnTools aims to simplify and enhance your coding experience.

Features

  • User Interaction Tools: Includes a user class with methods for colored text output and a choice menu for user-friendly interactions.

  • Database Management: Simplifies common SQLite database operations, such as creating tables, inserting data, viewing data, and more.

  • Random Number Generation: Provides a tool for generating random numbers within a specified range.

  • Word Count: Allows you to count the number of words in a given string.

  • Drive Letter: Retrieves the drive letter of the script"s directory.

  • Tasks Management (Example): An example module showcasing how to use KdnTools for managing tasks with a SQLite database.

Documentation

DataFetcher

The DataFetcher class is designed for making HTTP requests. It supports GET, POST, PUT, and DELETE operations.

Example Usage:

fetcher = DataFetcher(base_url="https://api.example.com", api_key="your_api_key")

Fetch data

data = fetcher.fetch_data(endpoint="users", params={"page": 1})

Post data

new_user = {"name": "John Doe", "email": "john@example.com"} response = fetcher.post_data(endpoint="users", data=new_user)

DbManage

The DbManage class simplifies SQLite database operations.

Example Usage:

db_manager = DbManage(db_location="example.db")

Create a table

columns = {"id": "INTEGER", "name": "TEXT", "age": "INTEGER"} db_manager.create_table(table_name="users", columns=columns)

Insert data

user_data = {"name": "John Doe", "age": 25} db_manager.insert_data(table_name="users", data=user_data)

View data

db_manager.view_data(table_name="users")

Remove data

db_manager.remove_data(table_name="users", condition="age > 30")

DriveLetter

The DriveLetter class retrieves the drive letter of the script"s directory.

print(f"Drive Letter: {DriveLetter()}")

Files

The Files class provides methods for writing, reading, and appending data to files.

Write to a file

Files.write(file_name, data_to_write)

Read from a file

read_data = Files.read_file(file_name)

print(f"Read Data: {read_data}")

Append to a file

data_to_append = "\nAppended Data!"

Files.append(file_name, data_to_append)

RandNumber

The RandNumber class generates a random number within a specified range.

Example Usage:

rand_num_generator = RandNumber(num1=1, num2=100)

random_number = str(rand_num_generator)

print(f"Random Number: {random_number}")

String

The String class provides various string manipulation tools.

ReverseString

input_str = "KdnTools"

reversed_str = str(String.ReverseString(input_str))

print(f"Reversed String: {reversed_str}")

Uppercase

input_str = "KdnTools"

uppercase_str = str(String.Uppercase(input_str))

print(f"Uppercase String: {uppercase_str}")

Lowercase

input_str = "KdnTools" lowercase_str = str(String.Lowercase(input_str)) print(f"Lowercase String: {lowercase_str}")

Capitalize

input_str = "KdnTools"

capitalized_str = str(String.Capitalize(input_str))

print(f"Capitalized String: {capitalized_str}")

Palindrome

input_str = "KdnTools"

palindrome_check = str(String.Palindrome(input_str))

print(f"Is Palindrome: {palindrome_check}")

SubstringCount

input_str = "KdnTools"

substring = "Kdn"

count_substring = str(String.SubstringCount(input_str, substring))

print(f"Occurrences of "{substring}": {count_substring}")

ReverseWords

input_str = "KdnTools is awesome"

reversed_words = str(String.ReverseWords(input_str))

print(f"Reversed Words: {reversed_words}")

User

The User class provides methods for user interaction, including colored text output and a choice menu.

Example Usage:

user = User()

Colored Text Output

user.Ctext(user.green, "Welcome to KdnTools!")

Choice Menu

choices = ["Option 1", "Option 2", "Option 3"]

selected_option = user.Choice("Please select an option:", choices)

Displaying the selected option

user.Ctext(user.blue, f"Selected Option: {choices[selected_option - 1]}")

Methods

Ctext(colour, text) Displays colored text in the console.

Parameters:

colour (str): Color code for the text (e.g., user.green).

text (str): The text to be displayed.

Choice(text, options)

Provides a user-friendly choice menu.

Parameters:

text (str): The prompt or question to be displayed.

options (list): List of options for the user to choose from.

Returns:

int: The index of the selected option in the provided list.

Installation

pip install KdnTools

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

KdnTools-1.9.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

KdnTools-1.9.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file KdnTools-1.9.1.tar.gz.

File metadata

  • Download URL: KdnTools-1.9.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for KdnTools-1.9.1.tar.gz
Algorithm Hash digest
SHA256 f4cab7fdeec3594f3ac4e3ff29a306e41fd5635ef181634d8784134669a8e2f0
MD5 ab367c7e222392fc8192dcdca9a56877
BLAKE2b-256 f158213da83db54bfd86c669a80b0a99269eff95696e55545a49170948a65f7b

See more details on using hashes here.

File details

Details for the file KdnTools-1.9.1-py3-none-any.whl.

File metadata

  • Download URL: KdnTools-1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for KdnTools-1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0e2b3c2db7730c3299af8042c401fb8e14398e300c9aefeee283e2b85bbf011
MD5 9eb6b54932bd9427c0dc4d9889575c64
BLAKE2b-256 6e1a1344c64c67d27896d20cdfa95f2f3e6920204db5ecc3929dbbae7f8d05ca

See more details on using hashes here.

Supported by

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