Skip to content

Commit

Permalink
Look and feel improved
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyid5416 committed Jan 19, 2023
1 parent 49ba453 commit ebb80de
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import re, threading, webbrowser, time, sys, json
from datetime import datetime
from typing import Callable
from colorama import Fore
from colorama import *
import requests




## ----------------------------------------------- Prints ------------------------------------------------ ##
def pp(text:str, fore=Fore.WHITE, end:str='\n'):
def pp(text:str, fore=Fore.WHITE, back=Back.RESET, end:str='\n'):
return print(
f'{fore}{text}{Fore.WHITE}',
f'{fore}{back}{text}{Back.RESET}{Fore.RESET}',
end=end
)

Expand All @@ -45,7 +45,8 @@ def pp_info_2(text):
def pp_error(text):
return pp(
text,
Fore.LIGHTRED_EX
Fore.WHITE,
Back.RED
)

def pp_input(text):
Expand All @@ -56,7 +57,7 @@ def pp_input(text):

def pp_question(text):
return input(
f'{Fore.WHITE}> {text}: {Fore.LIGHTBLUE_EX}'
f'{Fore.WHITE}{Back.BLUE}{Style.BRIGHT}> {text}:{Style.RESET_ALL}{Back.RESET}{Fore.LIGHTBLUE_EX} '
)


Expand Down Expand Up @@ -271,7 +272,7 @@ def __init__(self, settingsInstance:Settings) -> None:
''
),
'about': (
'About',
'About this app',
''
),
'raw': (
Expand All @@ -284,7 +285,7 @@ def __str__(self) -> str:
""" Returns: Proper formatted string of all choices """
choicesStr = ''
for a, b in self._choices.items():
choicesStr += f' {a:5} - {b[0]} {b[1]}\n'
choicesStr += f' {a:5} : {b[0]} {b[1]}\n'
return choicesStr

def get(self):
Expand Down Expand Up @@ -330,7 +331,6 @@ def __init__(self, availableChoices:Choices, settingsInstance:Settings):
case 'raw': self.switch_raw_setting()
case _: self.mainExtraction()


def getUserChoice(self):
""" Show user the choices and returns dict and the user choice """
# Printing choices
Expand All @@ -344,8 +344,7 @@ def getUserChoice(self):
if self.availableChoices.have(choice):
print()
return choice



def mainExtraction(self):
""" Main Links extraction """
# Ask for source location -> Get its data
Expand Down Expand Up @@ -573,7 +572,7 @@ def saveToFile(self, extractedLinks:set[str], summary:dict[str, int]):

def show_about_data(self):
data = {
'app name': 'Links Extractor',
'app name': app_name,
'saving directory': get_saving_directory(),
'settings file': self.settingsInstance.get_settings_file(),
'creator': os.path.split(
Expand All @@ -583,9 +582,9 @@ def show_about_data(self):
}
statement = ''
for a, b in data.items():
statement += f'{Fore.GREEN}{a.title():20} : {Fore.LIGHTBLUE_EX}{b}\n'
print(statement)
pp_info_2('Press <ctrl+c> any time to exit the app\n')
statement += f'{Fore.GREEN}{a.title():17} : {Fore.LIGHTBLUE_EX}{b}\n'
print(statement, end='')
pp_info_2(f'{" " * 15} (Press <ctrl+c> any time to exit the app)\n')

update_check = self.takeUserInput(
'Check for updates? (y/n) '
Expand Down

0 comments on commit ebb80de

Please sign in to comment.