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