ExtraFunctions 0.1.5__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {extrafunctions-0.1.5 → extrafunctions-0.1.7}/ExtraFunctions/__init__.py +133 -1
- extrafunctions-0.1.7/ExtraFunctions.egg-info/PKG-INFO +137 -0
- extrafunctions-0.1.7/ExtraFunctions.egg-info/requires.txt +1 -0
- {extrafunctions-0.1.5 → extrafunctions-0.1.7}/ExtraFunctions.egg-info/top_level.txt +0 -1
- extrafunctions-0.1.7/PKG-INFO +137 -0
- extrafunctions-0.1.7/README.md +129 -0
- extrafunctions-0.1.7/pyproject.toml +13 -0
- extrafunctions-0.1.5/ExtraFunctions.egg-info/PKG-INFO +0 -6
- extrafunctions-0.1.5/ExtraFunctions.egg-info/requires.txt +0 -1
- extrafunctions-0.1.5/PKG-INFO +0 -6
- extrafunctions-0.1.5/README.md +0 -1
- extrafunctions-0.1.5/pyproject.toml +0 -15
- {extrafunctions-0.1.5 → extrafunctions-0.1.7}/ExtraFunctions.egg-info/SOURCES.txt +0 -0
- {extrafunctions-0.1.5 → extrafunctions-0.1.7}/ExtraFunctions.egg-info/dependency_links.txt +0 -0
- {extrafunctions-0.1.5 → extrafunctions-0.1.7}/setup.cfg +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
1
2
|
import json
|
|
2
3
|
import os
|
|
3
4
|
import random as r
|
|
4
5
|
from PIL import Image
|
|
5
6
|
import time as t
|
|
7
|
+
import secrets as s
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
|
|
@@ -34,6 +36,7 @@ def negative(used):
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
|
|
39
|
+
|
|
37
40
|
|
|
38
41
|
class SaveError(Exception):
|
|
39
42
|
pass
|
|
@@ -338,4 +341,133 @@ def DistanceTranslate(amount, from_unit, to_unit):
|
|
|
338
341
|
raise ValueError(f"Unknown distance unit: {to_unit}")
|
|
339
342
|
|
|
340
343
|
metres = amount * units[from_unit]
|
|
341
|
-
return metres / units[to_unit]
|
|
344
|
+
return metres / units[to_unit]
|
|
345
|
+
def GeneratePassword(length):
|
|
346
|
+
characters = [
|
|
347
|
+
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
|
348
|
+
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
|
|
349
|
+
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
350
|
+
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
351
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
352
|
+
" ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",",
|
|
353
|
+
"-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]",
|
|
354
|
+
"^", "_", "`", "{", "|", "}", "~"]
|
|
355
|
+
password = ""
|
|
356
|
+
for i in range(length):
|
|
357
|
+
password += s.choice(characters)
|
|
358
|
+
return password
|
|
359
|
+
def DrawProgressBar(percent=0):
|
|
360
|
+
print("[", end="", flush=True)
|
|
361
|
+
for i in range(percent//10):
|
|
362
|
+
print("█", end="", flush=True)
|
|
363
|
+
for i in range((10 - (percent//10))):
|
|
364
|
+
print(" ", end="", flush=True)
|
|
365
|
+
print("]", end="", flush=True)
|
|
366
|
+
def UpdateProgressBar(Npercent):
|
|
367
|
+
print("\r[", end="", flush=True)
|
|
368
|
+
for i in range(Npercent//10):
|
|
369
|
+
print("█", end="", flush=True)
|
|
370
|
+
for i in range((10 - (Npercent//10))):
|
|
371
|
+
print(" ", end="", flush=True)
|
|
372
|
+
print("]", end="", flush=True)
|
|
373
|
+
def FormatTime(seconds):
|
|
374
|
+
seconds = int(seconds)
|
|
375
|
+
|
|
376
|
+
days = seconds // 86400
|
|
377
|
+
seconds %= 86400
|
|
378
|
+
|
|
379
|
+
hours = seconds // 3600
|
|
380
|
+
seconds %= 3600
|
|
381
|
+
|
|
382
|
+
minutes = seconds // 60
|
|
383
|
+
seconds %= 60
|
|
384
|
+
|
|
385
|
+
parts = []
|
|
386
|
+
|
|
387
|
+
if days:
|
|
388
|
+
parts.append(f"{days} day" + ("s" if days != 1 else ""))
|
|
389
|
+
|
|
390
|
+
if hours:
|
|
391
|
+
parts.append(f"{hours} hour" + ("s" if hours != 1 else ""))
|
|
392
|
+
|
|
393
|
+
if minutes:
|
|
394
|
+
parts.append(f"{minutes} minute" + ("s" if minutes != 1 else ""))
|
|
395
|
+
|
|
396
|
+
if seconds or not parts:
|
|
397
|
+
parts.append(f"{seconds} second" + ("s" if seconds != 1 else ""))
|
|
398
|
+
|
|
399
|
+
return " ".join(parts)
|
|
400
|
+
def CaesarEncrypt(text, shift):
|
|
401
|
+
result = ""
|
|
402
|
+
|
|
403
|
+
for character in text:
|
|
404
|
+
|
|
405
|
+
if character.isalpha():
|
|
406
|
+
|
|
407
|
+
if character.isupper():
|
|
408
|
+
start = ord("A")
|
|
409
|
+
else:
|
|
410
|
+
start = ord("a")
|
|
411
|
+
|
|
412
|
+
position = ord(character) - start
|
|
413
|
+
new_position = (position + shift) % 26
|
|
414
|
+
|
|
415
|
+
result += chr(start + new_position)
|
|
416
|
+
|
|
417
|
+
else:
|
|
418
|
+
result += character
|
|
419
|
+
|
|
420
|
+
return result
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def CaesarDecrypt(text, shift):
|
|
424
|
+
return CaesarEncrypt(text, -shift)
|
|
425
|
+
def DrawLoadingSpinner():
|
|
426
|
+
print("-", end="", flush=True)
|
|
427
|
+
def UpdateLoadingSpinner(rotation):
|
|
428
|
+
if rotation % 4 == 0:
|
|
429
|
+
rotate = "\r-"
|
|
430
|
+
elif rotation % 4 == 1:
|
|
431
|
+
rotate = "\r\\"
|
|
432
|
+
elif rotation % 4 == 2:
|
|
433
|
+
rotate = "\r|"
|
|
434
|
+
elif rotation % 4 == 3:
|
|
435
|
+
rotate = "\r/"
|
|
436
|
+
print( rotate, end="", flush=True)
|
|
437
|
+
def StartCountdown(seconds):
|
|
438
|
+
print(f"{seconds} seconds remaining", end = "", flush=True)
|
|
439
|
+
def UpdateCountdown(time):
|
|
440
|
+
if time>0:
|
|
441
|
+
print(f"\r{time} seconds remaining ", end = "", flush=True)
|
|
442
|
+
else:
|
|
443
|
+
print("\r ", end = "", flush = True)
|
|
444
|
+
def SlowWrite(txt, speed=0.5):
|
|
445
|
+
letters = list(txt)
|
|
446
|
+
for i in range(len(letters)):
|
|
447
|
+
try:
|
|
448
|
+
print(letters[i], end = "", flush = True)
|
|
449
|
+
except:
|
|
450
|
+
pass
|
|
451
|
+
t.sleep(speed)
|
|
452
|
+
def RandomChoice(choices, amount=1):
|
|
453
|
+
mchoices = deepcopy(choices)
|
|
454
|
+
clist = []
|
|
455
|
+
for i in range(amount):
|
|
456
|
+
choice = r.choice(mchoices)
|
|
457
|
+
mchoices.remove(choice)
|
|
458
|
+
clist += [choice]
|
|
459
|
+
return clist
|
|
460
|
+
def RemoveDuplicates(List):
|
|
461
|
+
return list(set(List))
|
|
462
|
+
def IsPalindrone(txt):
|
|
463
|
+
if negative(txt) == txt:
|
|
464
|
+
return True
|
|
465
|
+
else:
|
|
466
|
+
return False
|
|
467
|
+
def percentage(part, total):
|
|
468
|
+
return (part/total)*100
|
|
469
|
+
def ValidateInput(Input, type):
|
|
470
|
+
try:
|
|
471
|
+
return type(Input)
|
|
472
|
+
except:
|
|
473
|
+
raise TypeError(f"{Input} canot be turned into {type} format.")
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ExtraFunctions
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: A collection of useful Python utility functions.
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: Pillow==10
|
|
8
|
+
|
|
9
|
+
# ExtraFunctions
|
|
10
|
+
|
|
11
|
+
ExtraFunctions is a collection of useful Python functions designed to make common programming tasks simpler.
|
|
12
|
+
|
|
13
|
+
It includes utilities for saving data, generating random values, working with files, terminal displays, text manipulation, encryption, and more.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install ExtraFunctions using pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install ExtraFunctions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Functions
|
|
24
|
+
|
|
25
|
+
### General Utilities
|
|
26
|
+
|
|
27
|
+
* `negative(used)` — Reverses strings or makes numbers negative.
|
|
28
|
+
* `average(numbers)` — Calculates the average of a collection of numbers.
|
|
29
|
+
* `clamp(variable, top, bottom)` — Keeps a value between two limits.
|
|
30
|
+
* `WaitUntil(boolean, max_frames)` — Waits until a condition becomes true.
|
|
31
|
+
* `TimeLenFunc(func, *input)` — Measures how long a function takes to run.
|
|
32
|
+
* `attempt(func, *inputs, times)` — Attempts to run a function multiple times.
|
|
33
|
+
|
|
34
|
+
### Save System
|
|
35
|
+
|
|
36
|
+
* `Save(variable, name)` — Saves a variable.
|
|
37
|
+
* `SaveReset()` — Resets saved data.
|
|
38
|
+
* `SaveReturn(name)` — Returns a saved value.
|
|
39
|
+
* `DeleteSave(name)` — Deletes a saved value.
|
|
40
|
+
* `SaveChange(variable, name)` — Changes an existing saved value.
|
|
41
|
+
* `Exists(name)` — Checks whether a saved value exists.
|
|
42
|
+
* `ReturnSaved()` — Returns all saved data.
|
|
43
|
+
|
|
44
|
+
### Random Utilities
|
|
45
|
+
|
|
46
|
+
* `RandomString(length)` — Generates a random string.
|
|
47
|
+
* `RandomChoice(choices, amount=1)` — Selects one or more unique random choices.
|
|
48
|
+
* `WeightedRandom(options, values)` — Makes a weighted random selection.
|
|
49
|
+
* `PasswordGenerator(length)` — Generates a secure random password.
|
|
50
|
+
|
|
51
|
+
### Files and Data
|
|
52
|
+
|
|
53
|
+
* `FileExists(file)` — Checks whether a file exists.
|
|
54
|
+
* `load(file)` — Loads supported files.
|
|
55
|
+
|
|
56
|
+
### Terminal Utilities
|
|
57
|
+
|
|
58
|
+
* `DrawProgressBar(percent)` — Draws a terminal progress bar.
|
|
59
|
+
* `UpdateProgressBar(percent)` — Updates the progress bar.
|
|
60
|
+
* `DrawLoadingSpinner()` — Draws a loading spinner.
|
|
61
|
+
* `UpdateLoadingSpinner(rotation)` — Updates the loading spinner.
|
|
62
|
+
* `StartCountdown(seconds)` — Starts a terminal countdown.
|
|
63
|
+
* `UpdateCountdown(time)` — Updates a countdown.
|
|
64
|
+
* `SlowWrite(text, speed=0.5)` — Prints text gradually, like a typewriter.
|
|
65
|
+
|
|
66
|
+
### Text and Encryption
|
|
67
|
+
|
|
68
|
+
* `CaesarEncrypt(text, shift)` — Encrypts text using a Caesar cipher.
|
|
69
|
+
* `CaesarDecrypt(text, shift)` — Decrypts Caesar cipher text.
|
|
70
|
+
* `IsPalindrome(text)` — Checks whether text reads the same forwards and backwards.
|
|
71
|
+
|
|
72
|
+
### Other Utilities
|
|
73
|
+
|
|
74
|
+
* `FormatTime(seconds)` — Converts seconds into a readable time format.
|
|
75
|
+
* `RemoveDuplicates(list)` — Removes duplicate items from a list.
|
|
76
|
+
* `PlanetInfo(planet, info=False)` — Returns information about a planet.
|
|
77
|
+
* `DistanceTranslate(amount, from_unit, to_unit)` — Converts between supported distance units.
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
### Generate a password
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from ExtraFunctions import PasswordGenerator
|
|
85
|
+
|
|
86
|
+
password = PasswordGenerator(20)
|
|
87
|
+
|
|
88
|
+
print(password)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Create a progress bar
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from ExtraFunctions import DrawProgressBar, UpdateProgressBar
|
|
95
|
+
import time
|
|
96
|
+
|
|
97
|
+
DrawProgressBar(0)
|
|
98
|
+
|
|
99
|
+
for i in range(101):
|
|
100
|
+
UpdateProgressBar(i)
|
|
101
|
+
time.sleep(0.05)
|
|
102
|
+
|
|
103
|
+
print()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Slowly print text
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from ExtraFunctions import SlowWrite
|
|
110
|
+
|
|
111
|
+
SlowWrite("Hello, World!", 0.1)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Random choices
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from ExtraFunctions import RandomChoice
|
|
118
|
+
|
|
119
|
+
planets = ["Mercury", "Venus", "Earth", "Mars"]
|
|
120
|
+
|
|
121
|
+
print(RandomChoice(planets, 2))
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Errors
|
|
125
|
+
|
|
126
|
+
ExtraFunctions includes several custom errors:
|
|
127
|
+
|
|
128
|
+
* `UknownFormatError`
|
|
129
|
+
* `SaveError`
|
|
130
|
+
* `InfiniteError`
|
|
131
|
+
* `NonexistentPlanetError`
|
|
132
|
+
|
|
133
|
+
## Notes
|
|
134
|
+
|
|
135
|
+
ExtraFunctions is an independent Python project that is continually being expanded with new functions and utilities.
|
|
136
|
+
|
|
137
|
+
More features may be added in future updates.s
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Pillow==10
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ExtraFunctions
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: A collection of useful Python utility functions.
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: Pillow==10
|
|
8
|
+
|
|
9
|
+
# ExtraFunctions
|
|
10
|
+
|
|
11
|
+
ExtraFunctions is a collection of useful Python functions designed to make common programming tasks simpler.
|
|
12
|
+
|
|
13
|
+
It includes utilities for saving data, generating random values, working with files, terminal displays, text manipulation, encryption, and more.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install ExtraFunctions using pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install ExtraFunctions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Functions
|
|
24
|
+
|
|
25
|
+
### General Utilities
|
|
26
|
+
|
|
27
|
+
* `negative(used)` — Reverses strings or makes numbers negative.
|
|
28
|
+
* `average(numbers)` — Calculates the average of a collection of numbers.
|
|
29
|
+
* `clamp(variable, top, bottom)` — Keeps a value between two limits.
|
|
30
|
+
* `WaitUntil(boolean, max_frames)` — Waits until a condition becomes true.
|
|
31
|
+
* `TimeLenFunc(func, *input)` — Measures how long a function takes to run.
|
|
32
|
+
* `attempt(func, *inputs, times)` — Attempts to run a function multiple times.
|
|
33
|
+
|
|
34
|
+
### Save System
|
|
35
|
+
|
|
36
|
+
* `Save(variable, name)` — Saves a variable.
|
|
37
|
+
* `SaveReset()` — Resets saved data.
|
|
38
|
+
* `SaveReturn(name)` — Returns a saved value.
|
|
39
|
+
* `DeleteSave(name)` — Deletes a saved value.
|
|
40
|
+
* `SaveChange(variable, name)` — Changes an existing saved value.
|
|
41
|
+
* `Exists(name)` — Checks whether a saved value exists.
|
|
42
|
+
* `ReturnSaved()` — Returns all saved data.
|
|
43
|
+
|
|
44
|
+
### Random Utilities
|
|
45
|
+
|
|
46
|
+
* `RandomString(length)` — Generates a random string.
|
|
47
|
+
* `RandomChoice(choices, amount=1)` — Selects one or more unique random choices.
|
|
48
|
+
* `WeightedRandom(options, values)` — Makes a weighted random selection.
|
|
49
|
+
* `PasswordGenerator(length)` — Generates a secure random password.
|
|
50
|
+
|
|
51
|
+
### Files and Data
|
|
52
|
+
|
|
53
|
+
* `FileExists(file)` — Checks whether a file exists.
|
|
54
|
+
* `load(file)` — Loads supported files.
|
|
55
|
+
|
|
56
|
+
### Terminal Utilities
|
|
57
|
+
|
|
58
|
+
* `DrawProgressBar(percent)` — Draws a terminal progress bar.
|
|
59
|
+
* `UpdateProgressBar(percent)` — Updates the progress bar.
|
|
60
|
+
* `DrawLoadingSpinner()` — Draws a loading spinner.
|
|
61
|
+
* `UpdateLoadingSpinner(rotation)` — Updates the loading spinner.
|
|
62
|
+
* `StartCountdown(seconds)` — Starts a terminal countdown.
|
|
63
|
+
* `UpdateCountdown(time)` — Updates a countdown.
|
|
64
|
+
* `SlowWrite(text, speed=0.5)` — Prints text gradually, like a typewriter.
|
|
65
|
+
|
|
66
|
+
### Text and Encryption
|
|
67
|
+
|
|
68
|
+
* `CaesarEncrypt(text, shift)` — Encrypts text using a Caesar cipher.
|
|
69
|
+
* `CaesarDecrypt(text, shift)` — Decrypts Caesar cipher text.
|
|
70
|
+
* `IsPalindrome(text)` — Checks whether text reads the same forwards and backwards.
|
|
71
|
+
|
|
72
|
+
### Other Utilities
|
|
73
|
+
|
|
74
|
+
* `FormatTime(seconds)` — Converts seconds into a readable time format.
|
|
75
|
+
* `RemoveDuplicates(list)` — Removes duplicate items from a list.
|
|
76
|
+
* `PlanetInfo(planet, info=False)` — Returns information about a planet.
|
|
77
|
+
* `DistanceTranslate(amount, from_unit, to_unit)` — Converts between supported distance units.
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
### Generate a password
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from ExtraFunctions import PasswordGenerator
|
|
85
|
+
|
|
86
|
+
password = PasswordGenerator(20)
|
|
87
|
+
|
|
88
|
+
print(password)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Create a progress bar
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from ExtraFunctions import DrawProgressBar, UpdateProgressBar
|
|
95
|
+
import time
|
|
96
|
+
|
|
97
|
+
DrawProgressBar(0)
|
|
98
|
+
|
|
99
|
+
for i in range(101):
|
|
100
|
+
UpdateProgressBar(i)
|
|
101
|
+
time.sleep(0.05)
|
|
102
|
+
|
|
103
|
+
print()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Slowly print text
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from ExtraFunctions import SlowWrite
|
|
110
|
+
|
|
111
|
+
SlowWrite("Hello, World!", 0.1)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Random choices
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from ExtraFunctions import RandomChoice
|
|
118
|
+
|
|
119
|
+
planets = ["Mercury", "Venus", "Earth", "Mars"]
|
|
120
|
+
|
|
121
|
+
print(RandomChoice(planets, 2))
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Errors
|
|
125
|
+
|
|
126
|
+
ExtraFunctions includes several custom errors:
|
|
127
|
+
|
|
128
|
+
* `UknownFormatError`
|
|
129
|
+
* `SaveError`
|
|
130
|
+
* `InfiniteError`
|
|
131
|
+
* `NonexistentPlanetError`
|
|
132
|
+
|
|
133
|
+
## Notes
|
|
134
|
+
|
|
135
|
+
ExtraFunctions is an independent Python project that is continually being expanded with new functions and utilities.
|
|
136
|
+
|
|
137
|
+
More features may be added in future updates.s
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# ExtraFunctions
|
|
2
|
+
|
|
3
|
+
ExtraFunctions is a collection of useful Python functions designed to make common programming tasks simpler.
|
|
4
|
+
|
|
5
|
+
It includes utilities for saving data, generating random values, working with files, terminal displays, text manipulation, encryption, and more.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install ExtraFunctions using pip:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install ExtraFunctions
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Functions
|
|
16
|
+
|
|
17
|
+
### General Utilities
|
|
18
|
+
|
|
19
|
+
* `negative(used)` — Reverses strings or makes numbers negative.
|
|
20
|
+
* `average(numbers)` — Calculates the average of a collection of numbers.
|
|
21
|
+
* `clamp(variable, top, bottom)` — Keeps a value between two limits.
|
|
22
|
+
* `WaitUntil(boolean, max_frames)` — Waits until a condition becomes true.
|
|
23
|
+
* `TimeLenFunc(func, *input)` — Measures how long a function takes to run.
|
|
24
|
+
* `attempt(func, *inputs, times)` — Attempts to run a function multiple times.
|
|
25
|
+
|
|
26
|
+
### Save System
|
|
27
|
+
|
|
28
|
+
* `Save(variable, name)` — Saves a variable.
|
|
29
|
+
* `SaveReset()` — Resets saved data.
|
|
30
|
+
* `SaveReturn(name)` — Returns a saved value.
|
|
31
|
+
* `DeleteSave(name)` — Deletes a saved value.
|
|
32
|
+
* `SaveChange(variable, name)` — Changes an existing saved value.
|
|
33
|
+
* `Exists(name)` — Checks whether a saved value exists.
|
|
34
|
+
* `ReturnSaved()` — Returns all saved data.
|
|
35
|
+
|
|
36
|
+
### Random Utilities
|
|
37
|
+
|
|
38
|
+
* `RandomString(length)` — Generates a random string.
|
|
39
|
+
* `RandomChoice(choices, amount=1)` — Selects one or more unique random choices.
|
|
40
|
+
* `WeightedRandom(options, values)` — Makes a weighted random selection.
|
|
41
|
+
* `PasswordGenerator(length)` — Generates a secure random password.
|
|
42
|
+
|
|
43
|
+
### Files and Data
|
|
44
|
+
|
|
45
|
+
* `FileExists(file)` — Checks whether a file exists.
|
|
46
|
+
* `load(file)` — Loads supported files.
|
|
47
|
+
|
|
48
|
+
### Terminal Utilities
|
|
49
|
+
|
|
50
|
+
* `DrawProgressBar(percent)` — Draws a terminal progress bar.
|
|
51
|
+
* `UpdateProgressBar(percent)` — Updates the progress bar.
|
|
52
|
+
* `DrawLoadingSpinner()` — Draws a loading spinner.
|
|
53
|
+
* `UpdateLoadingSpinner(rotation)` — Updates the loading spinner.
|
|
54
|
+
* `StartCountdown(seconds)` — Starts a terminal countdown.
|
|
55
|
+
* `UpdateCountdown(time)` — Updates a countdown.
|
|
56
|
+
* `SlowWrite(text, speed=0.5)` — Prints text gradually, like a typewriter.
|
|
57
|
+
|
|
58
|
+
### Text and Encryption
|
|
59
|
+
|
|
60
|
+
* `CaesarEncrypt(text, shift)` — Encrypts text using a Caesar cipher.
|
|
61
|
+
* `CaesarDecrypt(text, shift)` — Decrypts Caesar cipher text.
|
|
62
|
+
* `IsPalindrome(text)` — Checks whether text reads the same forwards and backwards.
|
|
63
|
+
|
|
64
|
+
### Other Utilities
|
|
65
|
+
|
|
66
|
+
* `FormatTime(seconds)` — Converts seconds into a readable time format.
|
|
67
|
+
* `RemoveDuplicates(list)` — Removes duplicate items from a list.
|
|
68
|
+
* `PlanetInfo(planet, info=False)` — Returns information about a planet.
|
|
69
|
+
* `DistanceTranslate(amount, from_unit, to_unit)` — Converts between supported distance units.
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Generate a password
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from ExtraFunctions import PasswordGenerator
|
|
77
|
+
|
|
78
|
+
password = PasswordGenerator(20)
|
|
79
|
+
|
|
80
|
+
print(password)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Create a progress bar
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from ExtraFunctions import DrawProgressBar, UpdateProgressBar
|
|
87
|
+
import time
|
|
88
|
+
|
|
89
|
+
DrawProgressBar(0)
|
|
90
|
+
|
|
91
|
+
for i in range(101):
|
|
92
|
+
UpdateProgressBar(i)
|
|
93
|
+
time.sleep(0.05)
|
|
94
|
+
|
|
95
|
+
print()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Slowly print text
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from ExtraFunctions import SlowWrite
|
|
102
|
+
|
|
103
|
+
SlowWrite("Hello, World!", 0.1)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Random choices
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from ExtraFunctions import RandomChoice
|
|
110
|
+
|
|
111
|
+
planets = ["Mercury", "Venus", "Earth", "Mars"]
|
|
112
|
+
|
|
113
|
+
print(RandomChoice(planets, 2))
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Errors
|
|
117
|
+
|
|
118
|
+
ExtraFunctions includes several custom errors:
|
|
119
|
+
|
|
120
|
+
* `UknownFormatError`
|
|
121
|
+
* `SaveError`
|
|
122
|
+
* `InfiniteError`
|
|
123
|
+
* `NonexistentPlanetError`
|
|
124
|
+
|
|
125
|
+
## Notes
|
|
126
|
+
|
|
127
|
+
ExtraFunctions is an independent Python project that is continually being expanded with new functions and utilities.
|
|
128
|
+
|
|
129
|
+
More features may be added in future updates.s
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ExtraFunctions"
|
|
7
|
+
version = "0.1.7"
|
|
8
|
+
description = "A collection of useful Python utility functions."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"Pillow==10"
|
|
13
|
+
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Pillow==11.1.0
|
extrafunctions-0.1.5/PKG-INFO
DELETED
extrafunctions-0.1.5/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#DONT README
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "ExtraFunctions"
|
|
7
|
-
version = "0.1.5"
|
|
8
|
-
description = "A collection of useful Python utility functions. - 0.1.3 Adds a bug fix on save."
|
|
9
|
-
requires-python = ">=3.8"
|
|
10
|
-
dependencies = [
|
|
11
|
-
"Pillow==11.1.0"
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
[tool.setuptools.packages.find]
|
|
15
|
-
where = ["."]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|