Added Color Theme!
This commit is contained in:
+39
-28
@@ -19,37 +19,48 @@ validProjects = {
|
||||
'OGR-28' : 28,
|
||||
}
|
||||
|
||||
# Format Output
|
||||
class FORMAT:
|
||||
PINK = '\033[95m'
|
||||
BLUE = '\033[94m'
|
||||
CYAN = '\033[96m'
|
||||
GREEN = '\033[92m'
|
||||
YELLOW = '\033[93m'
|
||||
RED = '\033[91m'
|
||||
REGULAR = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
ITALICS = '\x1B[3m'
|
||||
# Text Colors & Formatting
|
||||
class Text:
|
||||
Pink = '\033[95m'
|
||||
Black = '\u001b[30m'
|
||||
Red = '\u001b[31m'
|
||||
Green = '\u001b[32m'
|
||||
Yellow = '\u001b[33m'
|
||||
Blue = '\u001b[34m'
|
||||
Magenta = '\u001b[35m'
|
||||
Cyan = '\u001b[36m'
|
||||
White = '\u001b[37m'
|
||||
Bold = '\033[1m'
|
||||
Italics = '\x1B[3m'
|
||||
Underline = '\033[4m'
|
||||
Reset = '\u001b[0m'
|
||||
|
||||
# Text Color Theme
|
||||
class Color:
|
||||
Theme1 = '\u001b[38;5;165m'
|
||||
Theme2 = '\u001b[38;5;164m'
|
||||
Theme3 = '\u001b[38;5;163m'
|
||||
Theme4 = '\u001b[38;5;162m'
|
||||
Theme5 = '\u001b[38;5;161m'
|
||||
|
||||
# Help Menu (Hint)
|
||||
def helpHint():
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1].lower() == 'help':
|
||||
helpMenu()
|
||||
print(FORMAT.GREEN + '\nType ' + FORMAT.BOLD + FORMAT.ITALICS + 'dnet-stats.py help' + FORMAT.REGULAR + FORMAT.GREEN + ' for the help menu.\n' + FORMAT.REGULAR)
|
||||
print(Text.Green + '\nType ' + Text.Bold + Text.Italics + 'dnet-stats.py help' + Text.Reset + Text.Green + ' for the help menu.\n' + Text.Reset)
|
||||
exit()
|
||||
|
||||
# Help Menu (Main)
|
||||
def helpMenu():
|
||||
print(
|
||||
FORMAT.BOLD + FORMAT.GREEN + '\nHelp Menu:\n' +
|
||||
FORMAT.BOLD + FORMAT.GREEN + '\nUsage: ' +
|
||||
FORMAT.REGULAR + FORMAT.GREEN + 'dnet-stats.py <username> <project>\n' +
|
||||
FORMAT.BOLD + FORMAT.GREEN + '\nProjects: ' +
|
||||
FORMAT.REGULAR + FORMAT.GREEN + 'RC5-56, RC5-64, RC5-72, OGR-24, OGR-25, OGR-26, OGR-27, OGR-28\n' +
|
||||
FORMAT.BOLD + FORMAT.GREEN + '\nExample: ' +
|
||||
FORMAT.REGULAR + FORMAT.GREEN + 'dnet-stats.py bluecat9@penguinized.net RC5-72\n' + FORMAT.REGULAR
|
||||
Text.Bold + Text.Green + '\nHelp Menu:\n' +
|
||||
Text.Bold + Text.Green + '\nUsage: ' +
|
||||
Text.Reset + Text.Green + 'dnet-stats.py <username> <project>\n' +
|
||||
Text.Bold + Text.Green + '\nProjects: ' +
|
||||
Text.Reset + Text.Green + 'RC5-56, RC5-64, RC5-72, OGR-24, OGR-25, OGR-26, OGR-27, OGR-28\n' +
|
||||
Text.Bold + Text.Green + '\nExample: ' +
|
||||
Text.Reset + Text.Green + 'dnet-stats.py Bluecat9@penguinized.net RC5-72\n' + Text.Reset
|
||||
)
|
||||
exit()
|
||||
|
||||
@@ -71,7 +82,7 @@ if len(sys.argv) == 3:
|
||||
projectId = validProjects[sys.argv[2].upper()]
|
||||
else:
|
||||
# otherwise, let the user know their project was not valid
|
||||
print(FORMAT.BOLD + FORMAT.RED + '\nError: ' + sys.argv[2].upper() + ' is not a valid project.\n' + FORMAT.REGULAR)
|
||||
print(Text.Bold + Text.Red + '\nError: ' + sys.argv[2].upper() + ' is not a valid project.\n' + Text.Reset)
|
||||
exit()
|
||||
|
||||
data = {'project_id':projectId,'st':myUser} # along with the project id
|
||||
@@ -84,13 +95,13 @@ if response: # if we received a response
|
||||
summary = soup.find('td',class_='htitle').text.lstrip() # find summary
|
||||
|
||||
if "Summary" in summary:
|
||||
print(FORMAT.BOLD + FORMAT.YELLOW + '\nUser: ' + FORMAT.RED + myUser + FORMAT.REGULAR) # print user
|
||||
print(Text.Bold + Color.Theme1 + '\nUser: ' + myUser + Text.Reset) # print user
|
||||
summary = " ".join(summary.split()) # remove extra spaces from summary
|
||||
summary = summary.split('/') # split summary and project into 2 strings
|
||||
project = summary[0] # store the project name from the summary into a variable
|
||||
print(FORMAT.BOLD + FORMAT.YELLOW + 'Project: ' + FORMAT.REGULAR + FORMAT.CYAN + project) # print project
|
||||
print(Text.Bold + Color.Theme2 + 'Project: ' + project) # print project
|
||||
else:
|
||||
print('\n' + FORMAT.BOLD + FORMAT.RED + 'Error: ' + myUser + ' not found for project ' + myProject + '.\n' + FORMAT.REGULAR) # notify if user not found
|
||||
print('\n' + Text.Bold + Text.Red + 'Error: ' + myUser + ' not found for project ' + myProject + '.\n' + Text.Reset) # notify if user not found
|
||||
exit()
|
||||
|
||||
line = 0
|
||||
@@ -107,14 +118,14 @@ if response: # if we received a response
|
||||
currentRank = currentRank.split('(')
|
||||
currentRank = currentRank[0]
|
||||
if line == 3: # print current and overall rank
|
||||
print (FORMAT.BOLD + FORMAT.YELLOW + 'Rank: ' + FORMAT.YELLOW + FORMAT.GREEN + FORMAT.UNDERLINE + currentRank + FORMAT.REGULAR)
|
||||
print (FORMAT.BOLD + FORMAT.YELLOW + 'Overall: ' + FORMAT.YELLOW + FORMAT.PINK + overallRank + FORMAT.REGULAR)
|
||||
print (Text.Bold + Color.Theme3 + 'Rank: ' + Text.Underline + currentRank + Text.Reset)
|
||||
print (Text.Bold + Color.Theme4 + 'Overall: ' + overallRank + Text.Reset)
|
||||
break
|
||||
|
||||
# get last update date
|
||||
lastUpdate = soup.find('td',class_="lastupdate").text.split()
|
||||
lastUpdate = lastUpdate[8].lstrip()
|
||||
print(FORMAT.BOLD + FORMAT.YELLOW + 'Updated: ' + FORMAT.BLUE + lastUpdate + FORMAT.REGULAR + '\n')
|
||||
print(Text.Bold + Color.Theme5 + 'Updated: ' + lastUpdate + Text.Reset + '\n')
|
||||
|
||||
else:
|
||||
print(FORMAT.BOLD + FORMAT.RED + 'An error has occured.' + FORMAT.REGULAR)
|
||||
print(Text.Bold + Text.Red + 'An error has occuRed.' + Text.Reset)
|
||||
|
||||
Reference in New Issue
Block a user