-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery Starbot ⭐ refactored Backist/Pybeaut #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| def Title(title: str): | ||
| def Title(self): | ||
| if System.Windows: | ||
| return _system(f"title {title}") | ||
| return _system(f"title {self}") |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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}") |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| def Command(command: str): | ||
| return _system(command) | ||
| def Command(self): | ||
| return _system(self) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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 |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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" |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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]) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Remove unnecessary casts to int, str, float or bool [×3] (
remove-unnecessary-cast)
| 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) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Replace a for append loop with list extend (
for-append-to-extend) - Simplify generator expression (
simplify-generator)
| 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}" |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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 | ||
| ) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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( |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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:] |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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): |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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:] |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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 |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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()) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| def _xspaces(text: str): | ||
| def _xspaces(self): | ||
| try: | ||
| col = _terminal_size().columns | ||
| except OSError: | ||
| return 0 | ||
| textl = text.splitlines() | ||
| textl = self.splitlines() |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| def _yspaces(text: str): | ||
| def _yspaces(self): | ||
| try: | ||
| lin = _terminal_size().lines | ||
| except OSError: | ||
| return 0 | ||
| textl = text.splitlines() | ||
| textl = self.splitlines() |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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()) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| def _length(ban1): | ||
| def _length(self): | ||
| bigestline = 0 | ||
|
|
||
| for line in ban1: | ||
| for line in self: |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| return bigestline | ||
|
|
||
| def _edit(ban1, size): | ||
| def _edit(self, size): |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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() |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| def SimpleCube(content: str) -> str: | ||
| def SimpleCube(self) -> str: | ||
| l = 0 | ||
| lines = content.splitlines() | ||
| lines = self.splitlines() |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| def DoubleCube(content: str) -> str: | ||
| return Box.Box(content, "╔═", "═╗", "╚═", "═╝", "║", "═", "║", "═") | ||
| def DoubleCube(self) -> str: | ||
| return Box.Box(self, "╔═", "═╗", "╚═", "═╝", "║", "═", "║", "═") |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name)
| 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()) |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Use str.join() instead of for loop (
use-join) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| 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 |
There was a problem hiding this comment.
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:
- The first argument to instance methods should be
self(instance-method-first-arg-name) - Replace unused for index with underscore [×5] (
for-index-underscore)
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
mainbranch, then run: