Skip to content

Conversation

@SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch https://github.com/sourcery-ai-bot/Pybeaut main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -68 to +70
def Title(title: str):
def Title(self):
if System.Windows:
return _system(f"title {title}")
return _system(f"title {self}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function System.Title refactored with the following changes:

Comment on lines -72 to +74
def Size(x: int, y: int):
def Size(self, y: int):
if System.Windows:
return _system(f"mode {x}, {y}")
return _system(f"mode {self}, {y}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function System.Size refactored with the following changes:

Comment on lines -76 to +77
def Command(command: str):
return _system(command)
def Command(self):
return _system(self)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function System.Command refactored with the following changes:

Comment on lines -105 to +109
def _cursor(visible: bool):
def _cursor(self):
ci = _CursorInfo()
handle = windll.kernel32.GetStdHandle(-11)
windll.kernel32.GetConsoleCursorInfo(handle, byref(ci))
ci.visible = visible
ci.visible = self
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Cursor._cursor refactored with the following changes:

Comment on lines -117 to +118
def _makeansi(col: str, text: str) -> str:
return f"\033[38;2;{col}m{text}\033[38;2;255;255;255m"

def _rmansi(col: str) -> str:
return col.replace('\033[38;2;', '').replace('m','').replace('50m', '').replace('\x1b[38', '')

def _makergbcol(var1: list, var2: list) -> list:
col = list(var1[:12])
for _col in var2[:12]:
col.append(_col)
for _col in reversed(col):
col.append(_col)
def _makeansi(self, text: str) -> str:
return f"\033[38;2;{self}m{text}\033[38;2;255;255;255m"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _MakeColors._makeansi refactored with the following changes:

Comment on lines -194 to +202
def StaticMIX(colors: list, _start: bool = True) -> str:
def StaticMIX(self, _start: bool = True) -> str:
rgb = []
for col in colors:
for col in self:
col = _MakeColors._rmansi(col=col)
col = col.split(';')
r = int(int(col[0]))
g = int(int(col[1]))
b = int(int(col[2]))
r = int(col[0])
g = int(col[1])
b = int(col[2])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colors.StaticMIX refactored with the following changes:

Comment on lines -209 to +224
def DynamicMIX(colors: list):
def DynamicMIX(self):
_colors = []
for color in colors:
if colors.index(color) == len(colors) - 1:
for color in self:
if self.index(color) == len(self) - 1:
break
_colors.append([color, colors[colors.index(color) + 1]])
colors = [_MakeColors._mixcolors(col1=color[0], col2=color[1], _reverse=False) for color in _colors]
_colors.append([color, self[self.index(color) + 1]])
self = [
_MakeColors._mixcolors(col1=color[0], col2=color[1], _reverse=False)
for color in _colors
]

final = []
for col in colors:
for col in col:
final.append(col)
return _MakeColors._reverse(colors=final)
for col in self:
final.extend(iter(col))
return _MakeColors._reverse(self=final)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colors.DynamicMIX refactored with the following changes:

Comment on lines -227 to +231
def Symbol(symbol: str, col: str, col_left_right: str, left: str = '[', right: str = ']') -> str:
return f"{col_left_right}{left}{col}{symbol}{col_left_right}{right}{Col.reset}"
def Symbol(self, col: str, col_left_right: str, left: str = '[', right: str = ']') -> str:
return f"{col_left_right}{left}{col}{self}{col_left_right}{right}{Col.reset}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colors.Symbol refactored with the following changes:

Comment on lines -419 to +423
def Color(color: str, text: str, end: bool = True) -> str:
return _MakeColors._maketext(color=color, text=text, end=end)
def Color(self, text: str, end: bool = True) -> str:
return _MakeColors._maketext(self=self, text=text, end=end)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Color refactored with the following changes:

Comment on lines -422 to +428
def Error(text: str, color: str = Colors.red, end: bool = False, spaces: bool = 1, enter: bool = True, wait: int = False) -> str:
def Error(self, color: str = Colors.red, end: bool = False, spaces: bool = 1, enter: bool = True, wait: int = False) -> str:
content = _MakeColors._maketext(
color=color, text="\n" * spaces + text, end=end)
color=color, self="\n" * spaces + self, end=end
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Error refactored with the following changes:

Comment on lines -440 to +459
def Vertical(color: list, text: str, speed: int = 1, start: int = 0, stop: int = 0, cut: int = 0, fill: bool = False) -> str:
color = color[cut:]
def Vertical(self, text: str, speed: int = 1, start: int = 0, stop: int = 0, cut: int = 0, fill: bool = False) -> str:
self = self[cut:]
lines = text.splitlines()
result = ""

nstart = 0
color_n = 0
for lin in lines:
colorR = color[color_n]
colorR = self[color_n]
if fill:
result += " " * \
_MakeColors._getspaces(
_MakeColors._getspaces(
lin) + "".join(_MakeColors._makeansi(colorR, x) for x in lin.strip()) + "\n"
else:
result += " " * \
_MakeColors._getspaces(
_MakeColors._getspaces(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Vertical refactored with the following changes:

Comment on lines -477 to +482
def Horizontal(color: list, text: str, speed: int = 1, cut: int = 0) -> str:
color = color[cut:]
def Horizontal(self, text: str, speed: int = 1, cut: int = 0) -> str:
self = self[cut:]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Horizontal refactored with the following changes:

Comment on lines -497 to +514
def Diagonal(color: list, text: str, speed: int = 1, cut: int = 0) -> str:
def Diagonal(self, text: str, speed: int = 1, cut: int = 0) -> str:

color = color[cut:]
self = self[cut:]
lines = text.splitlines()
result = ""
color_n = 0
for lin in lines:
carac = list(lin)
for car in carac:
colorR = color[color_n]
colorR = self[color_n]
result += " " * \
_MakeColors._getspaces(
_MakeColors._getspaces(
car) + _MakeColors._makeansi(colorR, car.strip())
if color_n + speed < len(color):
if color_n + speed < len(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Diagonal refactored with the following changes:

Comment on lines -518 to +523
def DiagonalBackwards(color: list, text: str, speed: int = 1, cut: int = 0) -> str:
color = color[cut:]
def DiagonalBackwards(self, text: str, speed: int = 1, cut: int = 0) -> str:
self = self[cut:]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.DiagonalBackwards refactored with the following changes:

Comment on lines -541 to +549
def Format(text: str, second_chars: list, mode, principal_col: Colors.col, second_col: str):
def Format(self, second_chars: list, mode, principal_col: Colors.col, second_col: str):
if mode == Colorate.Vertical:
ctext = mode(principal_col, text, fill=True)
ctext = mode(principal_col, self, fill=True)
else:
ctext = mode(principal_col, text)
ctext = mode(principal_col, self)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Colorate.Format refactored with the following changes:

Comment on lines -794 to +800
def GroupAlign(text: str, align: str = center):
def GroupAlign(self, align: str = center):
align = align.upper()
if align == Center.center:
return Center.XCenter(text)
return Center.XCenter(self)
elif align == Center.left:
return text
return self
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Center.GroupAlign refactored with the following changes:

Comment on lines -807 to +817
def TextAlign(text: str, align: str = center):
def TextAlign(self, align: str = center):
align = align.upper()
mlen = max(len(i) for i in text.splitlines())
if align == Center.center:

return "\n".join((' ' * int(mlen/2 - len(lin)/2)) + lin for lin in text.splitlines())
elif align == Center.left:
return text
return self
elif align == Center.right:
ntext = '\n'.join(' ' * (mlen - len(lin)) + lin for lin in text.splitlines())
return ntext
return '\n'.join(' ' * (mlen - len(lin)) + lin for lin in text.splitlines())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Center.TextAlign refactored with the following changes:

Comment on lines -824 to +829
def _xspaces(text: str):
def _xspaces(self):
try:
col = _terminal_size().columns
except OSError:
return 0
textl = text.splitlines()
textl = self.splitlines()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Center._xspaces refactored with the following changes:

Comment on lines -833 to +838
def _yspaces(text: str):
def _yspaces(self):
try:
lin = _terminal_size().lines
except OSError:
return 0
textl = text.splitlines()
textl = self.splitlines()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Center._yspaces refactored with the following changes:

Comment on lines -853 to +855
def Add(banner1, banner2, spaces=0, center=False):
def Add(self, banner2, spaces=0, center=False):
if center:
split1 = len(banner1.splitlines())
split1 = len(self.splitlines())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Add.Add refactored with the following changes:

Comment on lines -913 to +916
def _length(ban1):
def _length(self):
bigestline = 0

for line in ban1:
for line in self:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Add._length refactored with the following changes:

return bigestline

def _edit(ban1, size):
def _edit(self, size):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Add._edit refactored with the following changes:

Comment on lines -934 to +936
def Box(content: str, up_left: str, up_right: str, down_left: str, down_right: str, left_line: str, up_line: str, right_line: str, down_line: str) -> str:
def Box(self, up_left: str, up_right: str, down_left: str, down_right: str, left_line: str, up_line: str, right_line: str, down_line: str) -> str:
l = 0
lines = content.splitlines()
lines = self.splitlines()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Banner.Box refactored with the following changes:

Comment on lines -950 to +958
def SimpleCube(content: str) -> str:
def SimpleCube(self) -> str:
l = 0
lines = content.splitlines()
lines = self.splitlines()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Banner.SimpleCube refactored with the following changes:

Comment on lines -966 to +973
def DoubleCube(content: str) -> str:
return Box.Box(content, "╔═", "═╗", "╚═", "═╝", "║", "═", "║", "═")
def DoubleCube(self) -> str:
return Box.Box(self, "╔═", "═╗", "╚═", "═╝", "║", "═", "║", "═")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Banner.DoubleCube refactored with the following changes:

Comment on lines -969 to +983
def Lines(content: str, color = None, mode = Colorate.Horizontal, line = '═', pepite = 'ቐ') -> str:
def Lines(self, color = None, mode = Colorate.Horizontal, line = '═', pepite = 'ቐ') -> str:
l = 1
for c in content.splitlines():
for c in self.splitlines():
if len(c) > l:
l = len(c)
mode = Colorate.Horizontal if color is not None else (lambda **kw: kw['text'])
box = mode(text = f"─{line*l}{pepite * 2}{line*l}─", color = color)
assembly = box + "\n" + content + "\n" + box
final = ''
for lines in assembly.splitlines():
final += Center.XCenter(lines) + "\n"
return final
assembly = box + "\n" + self + "\n" + box
return ''.join(Center.XCenter(lines) + "\n" for lines in assembly.splitlines())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Banner.Lines refactored with the following changes:

Comment on lines -982 to +1010
def Arrow(icon: str = 'a', size: int = 2, number: int = 2, direction = 'right') -> str:
def Arrow(self, size: int = 2, number: int = 2, direction = 'right') -> str:
spaces = ' ' * (size + 1)
_arrow = ''
structure = (size + 2, [size * 2, size * 2])
count = 0
if direction == 'right':
for i in range(structure[1][0]):
line = (structure[0] * icon)
for _ in range(structure[1][0]):
line = structure[0] * self
_arrow += (' ' * count) + spaces.join([line] * (number)) + '\n'
count += 2

for i in range(structure[1][0] + 1):
line = (structure[0] * icon)
for _ in range(structure[1][0] + 1):
line = structure[0] * self
_arrow += (' ' * count) + spaces.join([line] * (number)) + '\n'
count -= 2
elif direction == 'left':
for i in range(structure[1][0]):
for _ in range(structure[1][0]):
count += 2

for i in range(structure[1][0]):
line = (structure[0] * icon)
for _ in range(structure[1][0]):
line = structure[0] * self
_arrow += (' ' * count) + spaces.join([line] * (number)) + '\n'
count -= 2

for i in range(structure[1][0] + 1):
line = (structure[0] * icon)
for _ in range(structure[1][0] + 1):
line = structure[0] * self
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Banner.Arrow refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant