1.0.40 (Increased limits on the menu function) and 1.0.41 (Windows "Support")

This commit is contained in:
Firepup Sixfifty 2024-08-30 12:15:36 -05:00
parent 969446bed6
commit 1f13093f38
Signed by: Firepup650
SSH key fingerprint: SHA256:cb8sEJwc0kQJ6/nMUhscWRe35itf0NFMdSKl3v4qt48
3 changed files with 230 additions and 169 deletions

View file

@ -1,7 +1,9 @@
# Firepup650
Package containing various shorthand things I use, and a few imports I almost always use
### Change log:
#### v.1.0.39:
#### v.1.0.41:
Windows "Support"
#### v.1.0.40:
Add offset mapping all the way up to 10 Billion, which exceeds the integer limit.
#### v.1.0.39:
Add offset mappings for exceeding 1 Million options, new limit is 10 Million options

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "firepup650"
version = "1.0.39"
version = "1.0.41"
authors = ["Firepup650 <firepyp650@gmail.com>"]
description = "Package containing various shorthand things I use, and a few imports I almost always use"
readme = "README.md"

View file

@ -1,10 +1,19 @@
"""Firepup650's PYPI Package"""
import os, sys, termios, tty, time, sqlite3, ast, pydoc # type: ignore[import]
import random as r
import fkeycapture as fkey
import fpsql as fql
fkey, termios, tty = None, None, None
from warnings import warn as ww
try:
import termios, tty, fkeycapture as fkey
except ImportError:
ww(
"Warning! This module has reduced functionality on Windows! I hope you know what you're doing!",
stackLevel=2,
)
import os, sys, time, sqlite3, ast, pydoc # type: ignore[import]
import random as r
import fpsql as fql
from typing import NoReturn, TypeVar, Type, Optional, List, Any, Union
from collections.abc import Iterable
@ -32,11 +41,15 @@ def alias(func):
return decorator
__VERSION__ = "1.0.34"
__NEW__ = "Adds methods to hide/show the cursor and a menu system"
__VERSION__ = "1.0.41"
__NEW__ = 'Windows "Support"'
__LICENSE__ = "MIT"
class NotImplementedOnWindowsException(NotImplementedException):
"""Exception raised when a Linux only method is called on a Windows machine"""
def flushPrint(*args) -> None:
"""# Function: flushPrint
Prints and flushes the provided args.
@ -124,6 +137,20 @@ def gp(
allowDelete: bool = False,
filler: str = "-",
) -> Union[str, bytes]:
raise NotImplementedOnWindowsException(
"This method is not implemented for Windows machines"
)
if fkey:
def gp(
keycount: int = 1,
chars: list = ["1", "2"],
bytes: bool = False,
allowDelete: bool = False,
filler: str = "-",
) -> Union[str, bytes]:
"""# Function: gp
Get keys and print them.
# Inputs:
@ -166,6 +193,21 @@ def gh(
allowDelete: bool = False,
filler: str = "-",
) -> Union[str, bytes]:
raise NotImplementedOnWindowsException(
"This method is not implemented for Windows machines"
)
if fkey:
def gh(
keycount: int = 1,
chars: list = ["1", "2"],
char: str = "*",
bytes: bool = False,
allowDelete: bool = False,
filler: str = "-",
) -> Union[str, bytes]:
"""# Function: gh
Get keys and print `char` in their place.
# Inputs:
@ -202,6 +244,14 @@ def gh(
def printt(text: str, delay: float = 0.1, newline: bool = True) -> None:
raise NotImplementedOnWindowsException(
"This method is not implemented for Windows machines"
)
if fkey:
def printt(text: str, delay: float = 0.1, newline: bool = True) -> None:
"""# Function: printt
Print out animated text!
# Inputs:
@ -633,11 +683,12 @@ class console:
# Raises:
None"""
ind = 1
while warning in console.__warnings__:
warning = f"{warning}({ind})"
warn = warning
while warn in console.__warnings__:
warn = f"{warning}({ind})"
ind += 1
console.__warnings__.append(warning)
ww(warning, class_, 2)
console.__warnings__.append(warn)
ww(warn, class_, 2)
@staticmethod
def error(*args, **kwargs) -> None:
@ -855,8 +906,16 @@ def hidden(func):
return wrapper
@hidden
def menu(options: dict, title: str = "") -> object:
raise NotImplementedOnWindowsException(
"This method is not implemented for Windows machines"
)
if fkey:
@hidden
def menu(options: dict, title: str = "") -> object:
"""# Function: menu
Uses a nice interactive for the provided options
# Inputs:
@ -902,7 +961,7 @@ def menu(options: dict, title: str = "") -> object:
indicatorOffset = -7
case (
21
): # 1000000000=9999999999 options (Ten Billion rolls over) (This exceeds integer limits, so if we get over this I've got no clue how.)
): # 1000000000-9999999999 options (Ten Billion rolls over) (This exceeds integer limits, so if we get over this I've got no clue how.)
indicatorOffset = -8
case _:
raise ValueError(