JynPopMod Python Module
Project description
MAIN: from JynPopMod import *
1. Timing and Delays
wait
Pauses execution for a specified duration in seconds, minutes, or hours.
Parameters:
key(str): 's' for seconds, 'm' for minutes, 'h' for hours.num(int): Number of units to wait.
Example Usage:
wait("m", 2) # Waits for 2 minutes.
timer_function
Runs a function after a delay.
Parameters:
func(callable): Function to run.seconds(int): Delay in seconds.
Example Usage:
timer_function(lambda: print("Time's up!"), 5)
start_timer
Starts a timer and executes a callback after the timer ends.
Parameters:
seconds(int): Duration of the timer.callback(callable): Function to execute after the timer.
Example Usage:
start_timer(3, lambda: print("Timer completed!"))
2. Conditional Function Calls
iftrue
Calls a function if a condition is true.
Parameters:
Var(bool): Condition to check.function(callable): Function to call if true.
Example Usage:
iftrue(3 > 1, lambda: print("Condition is true!"))
iffalse
Calls a function if a condition is false.
Example Usage:
iffalse(3 > 5, lambda: print("Condition is false!"))
oncondit
Calls one of two functions based on a condition.
Parameters:
condition(bool): Condition to check.function_true(callable): Function to call if true.function_false(callable): Function to call if false.
Example Usage:
oncondit(5 > 3, lambda: print("True!"), lambda: print("False!"))
3. Looping
until
Runs a block repeatedly until a condition becomes true.
Parameters:
function(callable): Function that returns a boolean to break the loop.whattodo: Code block to execute in the loop.
Example Usage:
until(lambda: 1 == 1, print("This will run only once."))
repeat
Runs a function a specified number of times.
Parameters:
function(callable): Function to repeat.times(int): Number of repetitions.
Example Usage:
repeat(lambda: print("Repeated!"), 3)
repeat_forever
Continuously runs a function in an infinite loop.
Example Usage:
repeat_forever(lambda: print("Infinite loop!"))
4. Utility
ifnull
Replaces None or empty values with a default.
Parameters:
_v: Value to check._d: Default value.
Example Usage:
value = ifnull(None, "Default Value")
switch_case
Implements a switch-case structure.
Parameters:
_v: Value to check._c: Dictionary mapping values to results or functions.d: Default value.
Example Usage:
result = switch_case(2, {1: "One", 2: lambda: "Two"}, "Default")
5. String and File Operations
replace
Replaces occurrences of a substring in a string.
Example Usage:
new_string = replace("hello world", "world", "Python")
generate_random_string
Generates a random string of specified length.
Parameters:
length(int): Length of the string.
Example Usage:
random_string = generate_random_string(10)
gs
Gets the source code of a function.
Example Usage:
print(gs(switch_case))
6. Task Management
parallel
Runs multiple functions in parallel.
Parameters:
*functions: Functions to run.
Example Usage:
parallel(lambda: print("Task 1"), lambda: print("Task 2"))
start_background_task
Starts a task in a background thread.
Example Usage:
start_background_task(lambda: print("Running in the background!"))
7. Networking and Input
get_ip_address
Returns the current IP address of the machine.
Example Usage:
ip_address = get_ip_address()
send_email
Sends an email using SMTP.
Parameters:
subject(str): Email subject.body(str): Email body.to_email(str): Recipient email.mailname(str): Sender email.mailpass(str): Sender's email password.
Example Usage:
send_email("Test Subject", "Hello, World!", "to@example.com", "your_email@gmail.com", "your_password")
get_weather
Fetches weather information for a city.
Parameters:
city(str): City name.api_key(str): API key for OpenWeatherMap.
Example Usage:
weather = get_weather("New York", "your_api_key")
8. Image Processing
convert_image_to_grayscale
Converts an image to grayscale.
Parameters:
image_path(str): Path to the image.output_path(str): Path to save the grayscale image.
Example Usage:
convert_image_to_grayscale("color.jpg", "grayscale.jpg")
9. Hotkey and Keypress
hotdog
Triggers a sequence of hotkeys.
Example Usage:
hotdog("ctrl", "c") # Copies the current selection.
keypress
Simulates a keypress.
Example Usage:
keypress("enter")
10. Error Handling
safe_run
Runs a function safely, catching exceptions.
Example Usage:
safe_run(lambda: 1 / 0)
nocrash
Decorator to handle exceptions in functions.
Example Usage:
def risky_function():
return 1 / 0
nocrash(risky_function) # More effective for gui/interface.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jynpopmod-2.6.tar.gz.
File metadata
- Download URL: jynpopmod-2.6.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2038c60a72ad21dcd87c26a274372a5a66a045973031f3b08c9d70cd7cb750db
|
|
| MD5 |
8f21b5e3a6afd1889a30f0d2ea9f7c30
|
|
| BLAKE2b-256 |
d143b349570561461da40fdb80c603ae5e5d4974bd3b45b72299de206500d671
|
File details
Details for the file JynPopMod-2.6-py3-none-any.whl.
File metadata
- Download URL: JynPopMod-2.6-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89e479775133554242a3195774c7ed59182764f0980d7d2aa67acf546b6274f9
|
|
| MD5 |
cd908a44f988c894545015a4e3eb1ff5
|
|
| BLAKE2b-256 |
9052e543c5ca3552799002160cea9bbf2aa02cfed64d08cf5da29bee09ef8d70
|