Skip to content

Commit

Permalink
Removed direct output to console, redone color output, fixed formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
rmicheev committed Nov 29, 2023
1 parent 1aa04ae commit a5a4a97
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 153 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pyperclip==1.8.2
pytesseract==0.3.10
pytest==7.2.2
python_Levenshtein==0.20.9
colorama==0.4.6
59 changes: 21 additions & 38 deletions src/pygats/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def print_header(level, text):
level (int): Level of header. Count of # in markdown header.
text (string): Header text
"""
print()
header_level = '#' * level
print(f'{header_level} {text}')
print()
Expand All @@ -28,20 +27,7 @@ def print_para(text):
Args:
text (string): paragraph text
"""
print()
print(f'{text}')
print()

@staticmethod
def print_footer(text):
"""
Print footer
Args:
text (string): footer text
"""
print()
print(f'{text}')
print(text)
print()

@staticmethod
Expand All @@ -57,36 +43,33 @@ def print_code(code):
print('```')

@staticmethod
def print_img(img_path):
def print_img(img_path, text):
"""
Print image path
Args:
img_path (string): path to image
"""
print(f'![Screenshot]({img_path})')
print(f'![{text}]({img_path})')
print()

@staticmethod
def print_bold(text):
"""
Print Markdown bold text
def print_color_text(text: str, color: str):
"""
Display text in a specific color
Args:
text (string): bold text
"""
print(f'**{text}**')
print()

Args:
text (str): text to be printed
color (str): text color
"""
# pylint: disable=consider-using-f-string
colors = {
'red': "\033[31m{}\033[0m",
'green': "\033[32m{}\033[0m",
'yellow': "\033[33m{}\033[0m",
'blue': "\033[34m{}\033[0m",
'purple': "\033[35m{}\033[0m",
'light blue': "\033[36m{}\033[0m",
'white': "\033[37m{}\033[0m"
}
if colors.get(color):
print(colors.get(color).format(text))
else:
print(text)
@staticmethod
def print_list(text):
"""
Print Markdown unordered list text
Args:
text (string): unordered list text
"""
print(f'* {text}')
Loading

0 comments on commit a5a4a97

Please sign in to comment.