Added in Changes

This commit is contained in:
Manitej Boorgu
2020-08-06 23:35:10 +00:00
parent 6e03ee16a6
commit f20c8bb9bc
3 changed files with 67 additions and 65 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
"""The replit python module."""
from . import maqpy
from . import utils
from . import termutils
from .audio import Audio
from .database import db
+22 -22
View File
@@ -58,29 +58,29 @@ class Link(HTMLElement):
class Page(flask.Response):
"""Represents an HTML page."""
"""Represents an HTML page."""
def __init__(self, title: str = None, head: str = "", body: str = "") -> None:
"""Initialize the class.
def __init__(self, title: str = None, head: str = "", body: str = "") -> None:
"""Initialize the class.
Args:
title (str): The title of the page. If not provided no title tag will be sent.
head (str): The HTML to put in the head of the page. Defaults to nothing.
body (str): The HTML to put in the body of the page. Defaults to nothing.
"""
self.title = title
self.head = head
self.body = body
Args:
title (str): The title of the page. If not provided no title tag will be sent.
head (str): The HTML to put in the head of the page. Defaults to nothing.
body (str): The HTML to put in the body of the page. Defaults to nothing.
"""
self.title = title
self.head = head
self.body = body
title_html = f"<title>{self.title}</title>\n " if self.title else ""
super().__init__(
title_html = f"<title>{self.title}</title>\n " if self.title else ""
super().__init__(
f"""<!DOCTYPE html>
<html>
<head>
{title_html}{self.head}
</head>
<body>
{self.body}
</body>
</html>"""
)
<html>
<head>
{title_html}{self.head}
</head>
<body>
{self.body}
</body>
</html>"""
)
@@ -4,23 +4,11 @@ def clear() -> None:
"""Clear the terminal."""
print("\033[H\033[2J", end="", flush=True)
class hexdec():
def __init__(self, hexvalue : str):
class color():
'''
Dynamic Color: Accepts RGB Color
'''
'''
Convert Hex Value to RGB
then generate an ANSI escape code
'''
hexvalue = hexvalue.lstrip('#')
self.rgb = tuple(int(hexvalue[i:i+2], 16) for i in (0, 2, 4))
r, g, b = self.rgb
self.fg = f'\033[38;2;{r};{g};{b}m'
self.bg = f'\033[48;2;{r};{g};{b}m'
class rgb():
def __init__(self, r : int, g : int, b : int):
'''
@@ -32,20 +20,34 @@ class rgb():
'''
if r < 0 or g < 0 or b < 0:
raise ValueError('RGB Pallete - No Color Support for colors under 0')
raise ValueError('No Color Support for colors under 0')
if r > 255 or g > 255 or b > 255:
raise ValueError('RGB Pallete - No Color Support for colors over 255')
raise ValueError('No Color Support for colors over 255')
self.rgb = (r, g, b)
self.fg = f'\033[38;2;{r};{g};{b}m'
self.bg = f'\033[48;2;{r};{g};{b}m'
@classmethod
def hexdec(cls, hexvalue : str):
'''
Convert Hex Value to RGB
then generate an ANSI escape code
'''
try:
hexvalue = hexvalue.lstrip('#')
r, g, b = tuple(int(hexvalue[i:i+2], 16) for i in (0, 2, 4))
except Exception as e:
raise ValueError(f'Error while converting Hex to RGB - {e}')
return cls(r, g, b)
class bit():
def __init__(self, value : int):
'''
Use a 8bit colorpallete
colors from 0-255 (256 total)
Exceptions:
ValueError
'''
if value > 255:
@@ -81,25 +83,25 @@ class attr():
reset = attr('reset').attr
bold = attr('bold').attr
italic = attr('italic').attr
red = rgb(255, 0, 0)
orange = rgb(255, 165, 0)
yellow = rgb(255,255,0)
green = rgb(0,255,0)
blue = rgb(0,0,255)
indigo = rgb(75,0,130)
violet = rgb(238,130,238)
purple = rgb(128,0,128)
pink = rgb(255,105,180)
brown = rgb(165,42,42)
brightred = rgb(250,128,114)
brightorange = rgb(255,215,0)
brightyellow = rgb(255, 255, 102)
brightgreen = rgb(102, 255, 102)
brightblue = rgb(102, 178, 255)
brightpurple = rgb(178, 102, 255)
darkred = rgb(139,0,0)
darkorange = rgb(255,140,0)
darkyellow = rgb(204, 204, 0)
darkgreen = rgb(0, 153, 0)
darkblue = rgb(0, 0, 204)
darkpurple = rgb(102, 0, 204)
red = color(255, 0, 0)
orange = color(255, 165, 0)
yellow = color(255,255,0)
green = color(0,255,0)
blue = color(0,0,255)
indigo = color(75,0,130)
violet = color(238,130,238)
purple = color(128,0,128)
pink = color(255,105,180)
brown = color(165,42,42)
brightred = color(250,128,114)
brightorange = color(255,215,0)
brightyellow = color(255, 255, 102)
brightgreen = color(102, 255, 102)
brightblue = color(102, 178, 255)
brightpurple = color(178, 102, 255)
darkred = color(139,0,0)
darkorange = color(255,140,0)
darkyellow = color(204, 204, 0)
darkgreen = color(0, 153, 0)
darkblue = color(0, 0, 204)
darkpurple = color(102, 0, 204)