Skip to main content

A Python library for generating random names using vowels and consonants.

Project description

ConsoleMasterPy

ConsoleMasterPy is a Python library that simplifies console manipulation on Windows systems. It provides functionalities for changing console colors, hiding/showing the cursor, setting console window size, and more.

Installation

You can install ConsoleMasterPy using pip:

pip install ConsoleMasterPy

Usage

from ConsoleMasterPy import ConsoleMaster

Create a new console window

console = ConsoleMaster(title="My Console", font_size=17, window_width=30, window_height=25)

Change console colors

console.change_console_color(background_color=(0, 0, 0), foreground_color=(255, 255, 255))

Print with custom colors

console.print_with_color(rgb_background=(0, 0, 0), rgb_foreground=(255, 255, 255), element_to_print="Hello, World!")

Change console window size

console.change_windows_size(width=40, height=30)

Hide the cursor

console.hide_cursor()

Pause execution until user input

console.pause()

Go to specified position (x, y) in the console window

console.go_xy(x=10, y=5)

Change pixel size of the console font

console.change_pixel_size(size=20)

Clean a specified zone in the console window

console.clean_zone(x_coord_init=5, y_coord_init=5, x_coord_end=15, y_coord_end=10)

Clean the entire console window

console.clean_windows()

Pause execution until user input

console.pause()

Additional Functions

generate_name()

This function generates a random name with a mix of vowels and consonants.

from ConsoleMasterPy import generate_name

name = generate_name()
print(name)

exception_handler Function

The exception_handler function is a decorator used to handle exceptions within functions. It catches any exceptions that occur during the execution of the decorated function and logs the error message, along with a timestamp, to a file named log.txt. This decorator ensures that the program can continue running smoothly even if an exception occurs, providing better error handling and debugging.

Parameters

  • func: The function to be decorated with exception handling.

Example Usage

@exception_handler
def my_function():
    # Code that might raise an exception
    pass

Example usage - Game of Life of John Horton Conway

from ConsoleMasterPy import ConsoleMaster, exception_handler
import random
from time import sleep

def copy_matrix(matrix):
    return [row[:] for row in matrix]

width, height = 35, 35
console_manager = ConsoleMaster("GAME OF LIFE", 13, width, height)

@exception_handler
def main():
    generation_counter = 0
    
    while True:
        if generation_counter == 0:
            current_matrix = [[0 for x in range(width)] for y in range(height)]
            next_matrix = copy_matrix(current_matrix)
            cell_color = [random.randint(0, 255) for _ in range(3)]

            live_cell_rules = [random.randint(0, 1) for _ in range(9)]
            birth_rules = [random.randint(0, 1) for _ in range(9)]

            for x in range(width):
                next_matrix[x][0] = 0
                next_matrix[x][height - 1] = 0
                next_matrix[x][1] = 1
                next_matrix[x][height - 2] = 1

            for y in range(height):
                next_matrix[0][y] = 0
                next_matrix[width - 1][y] = 0
                next_matrix[1][y] = 1
                next_matrix[width - 2][y] = 1

            for x in range(1, width - 1):
                for y in range(1, height - 1):
                    cell_value = next_matrix[x][y]
                    console_manager.go_xy(x, y)
                    color = cell_color if cell_value else [0, 0, 0]
                    console_manager.print_with_color(color, [0, 0, 0], " ")
            generation_counter = 300

        generation_counter -= 1

        current_matrix = copy_matrix(next_matrix)
        for x in range(1, width - 1):
            for y in range(1, height - 1):
                neighbors = [(x + i, y + j) for i in range(-1, 2) for j in range(-1, 2) if not (i == 0 and j == 0)]
                count = sum(1 for i, j in neighbors if 0 <= i < width and 0 <= j < height and current_matrix[i][j] == 1)

                if current_matrix[x][y] == 1:
                    if not live_cell_rules[count]:
                        next_matrix[x][y] = 0
                        console_manager.go_xy(x, y)
                        console_manager.print_with_color([0, 0, 0], [0, 0, 0], " ")
                    else:
                        next_matrix[x][y] = 1
                else:
                    if birth_rules[count]:
                        next_matrix[x][y] = 1
                        console_manager.go_xy(x, y)
                        console_manager.print_with_color(cell_color, [0, 0, 0], " ")
                    else:
                        next_matrix[x][y] = 0
        sleep(0.05)

main()

License

ConsoleMasterPy is licensed under the MIT

random_name_generator_rendev

random_name_generator_rendev is a Python library for generating random names using a mix of vowels and consonants. The generated names may include spaces and apostrophes to simulate natural or fantasy-like names.

Installation

Install using pip:

pip install random_name_generator_rendev

Usage

from random_name_generator import generate_name

name = generate_name()
print(name)

Functionality

  • Generates random names using uppercase and lowercase vowels and consonants.
  • Names may include spaces and apostrophes for more natural or fantasy-like results.

License

random_name_generator_rendev is licensed under the MIT License.

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

random_name_generator_rendev-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

random_name_generator_rendev-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file random_name_generator_rendev-1.0.0.tar.gz.

File metadata

File hashes

Hashes for random_name_generator_rendev-1.0.0.tar.gz
Algorithm Hash digest
SHA256 12f680f7207a5c30581e691192db99eb5b6e8fc03d3b380d5185ea0e643bdd63
MD5 059e202a19eafcdca5bb8d1620805866
BLAKE2b-256 9d4486c55cee3377ed87a58f78e3b56603a2fac0c10bbed9d1235ad4b6ebef3e

See more details on using hashes here.

File details

Details for the file random_name_generator_rendev-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for random_name_generator_rendev-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0472a71c6f1e3db552395df42197e74bba2d7e8a983e344857840319a98db448
MD5 e022d8fa840b696363494fc74d2ae015
BLAKE2b-256 f536fc860c773e26cf24a171a47e81a2f49749868ea88b38e4369a386ec2246c

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