Skip to main content

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

Metadata

Release files for KdnTools 1.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for KdnTools 1.9.1
File Size Uploaded
KdnTools-1.9.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for KdnTools 1.9.1
File Interpreter ABI Platform
KdnTools-1.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / KdnTools-1.9.1.tar.gz

Download URL KdnTools-1.9.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4cab7fdeec3594f3ac4e3ff29a306e41fd5635ef181634d8784134669a8e2f0
BLAKE2b-256 checksum
How to use checksums
f158213da83db54bfd86c669a80b0a99269eff95696e55545a49170948a65f7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / KdnTools-1.9.1-py3-none-any.whl

Download URL KdnTools-1.9.1-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0e2b3c2db7730c3299af8042c401fb8e14398e300c9aefeee283e2b85bbf011
BLAKE2b-256 checksum
How to use checksums
6e1a1344c64c67d27896d20cdfa95f2f3e6920204db5ecc3929dbbae7f8d05ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.9.1 This release

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.9

2 release files

1.6.8

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page