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.7.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

KdnTools-1.7.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for KdnTools-1.7.2.tar.gz
Algorithm Hash digest
SHA256 e658e0574be18f141bd5dee6be603457ec5f4d8b136a969322d03c116d72abb3
MD5 9da7f830bd85fbcb9d302dfa81ce92e8
BLAKE2b-256 703defce0858c3241d6b84dc33f55a2ec90d503b0c9b4dbacca2c82df612997f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KdnTools-1.7.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 913d02e7411560b4d3b6b60545840ffea7d57fee2b5cf16f686720f4536b4ea9
MD5 dac1e2de1c7763baef785693992684a7
BLAKE2b-256 4d5400717c349ddb24a71e792353471a02ff03064e3ce0af7515b074c3998291

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