def help () : print("This is OIPROG") print("A cli application to keep oi status in track") print("If you are new, please do " + colorize("oiprog init", 'red')) print("If you want to go to settings, please do " + colorize("oiprog config", 'red')) print("If you have already set the configurations, please do " + colorize("oiprog", 'red')) print("If there're any problems, please contact us at " + colorize('github.com/vzsky/OI_Progress', 'yellow'))
def test_failing(self): string = 'test' color.COLORED = True fails = False try: color.colorize(string, 'sua mae', 'eu e vc') except RuntimeError: fails = True self.assertTrue(fails, "Must fails with RunTime if fails")
def procedure_color(increment): """Choose output color when incrementing/decrementing.""" if increment >= 1: procedure = "Incrementing" procedure_color = "green" else: procedure = "Decrementing" procedure_color = "red" return colorize(procedure, procedure_color)
def procedure_color(increment): """Choose output color when incrementing/decrementing.""" if increment >= 1: procedure = 'Incrementing' procedure_color = 'green' else: procedure = 'Decrementing' procedure_color = 'red' return colorize(procedure, procedure_color)
def _spinner(control): animation = ''.join(x * 5 for x in animation_diagram) if not sys.stdout.isatty(): # not send to pipe/redirection return anim = zip(cycle(animation), cycle(animation_spinner)) for n, start_end_anim in enumerate(anim): start, end = start_end_anim padding = '█' * int(20 * abs(sin(0.05 * (n + control.position)))) padding_colored = color.colorize(padding, 'cyan') banner = '{} {} {}'.format(start, control.message, end) banner_colored = color.colorize(banner, 'cyan') message = '\r' + padding_colored + banner_colored sys.stdout.write(message) time.sleep(0.05) sys.stdout.write('\r' + len(message) * ' ') sys.stdout.write(2 * len(message) * "\010") if control.done: control.position = n break sys.stdout.write(len(message) * ' ') sys.stdout.write('\r' + 2 * len(message) * "\010")
def _spinner(control): slow_braily = ''.join(x * 5 for x in braily) if not sys.stdout.isatty(): # not send to pipe/redirection return stream_animation = AnimationStream(sys.stdout) template = '{padding} {start} {control.message} {end}' for n, (start, end) in enumerate(zip(cycle(slow_braily), cycle(pulse))): padding = space_wave(n, control.position) message = '\r' + color.colorize(template.format_map(locals()), 'cyan') stream_animation.write(message) time.sleep(0.05) stream_animation.erase(message) if control.done: control.position = n break stream_animation.erase(message)
def _spinner(control): slow_braily = ''.join(x * 5 for x in BRAILY) if not sys.stdout.isatty(): # not send to pipe/redirection return stream_animation = AnimationStream(sys.stdout) template = '{padding} {start} {control.message} {end}' for n, (start, end) in enumerate(zip(cycle(slow_braily), cycle(PULSE))): padding = space_wave(n, control.position) message = '\r' + color.colorize(template.format_map(locals()), 'cyan') stream_animation.write(message) time.sleep(0.05) stream_animation.erase(message) if control.done: control.position = n break stream_animation.erase(message)
def score_color(score): """Choose color of output based on how high the score is.""" if score == 10: return colorize(score, "green", "bold") if score >= 9: return colorize(score, "cyan", "bold") elif score >= 7: return colorize(score, "blue", "bold") elif score >= 5: return colorize(score, "yellow", "bold") elif score >= 1: return colorize(score, "red", "bold") else: return colorize("-", "pink", "bold")
def score_color(score): """Choose color of output based on how high the score is.""" if score == 10: return colorize(score, 'green', 'bold') if score >= 9: return colorize(score, 'cyan', 'bold') elif score >= 7: return colorize(score, 'blue', 'bold') elif score >= 5: return colorize(score, 'yellow', 'bold') elif score >= 1: return colorize(score, 'red', 'bold') else: return colorize('-', 'pink', 'bold')
def _spinner(control): if not sys.stdout.isatty(): # not send to pipe/redirection return colorize_no_reset = partial(color.colorize, autoreset=False) template = '{padding} {start} {message} {end}' NBRAILY = ''.join(x * 5 for x in asciiart.BRAILY) iterator = zip(cycle(NBRAILY), cycle(asciiart.VPULSE)) for i, (start, end) in enumerate(iterator): padding = control.fpadding(i + control.bias) info = dict(message=colorize_no_reset(control.message, 'red'), padding=colorize_no_reset(padding, 'blue'), start=colorize_no_reset(start, 'cyan'), end=color.colorize(end, 'cyan')) message = '\r' + template.format_map(info) with control.stream.lock: control.stream.write(message) if not control.running: control.bias = i break control.stream.erase(message)
def test_colorize_disabled(self): string = 'test' color.COLORED = False colored_string = color.colorize(string, 'cyan') self.assertEqual(string, colored_string, "Disabled; must be the same")
def number (str) : return colorize(str, themes[theme]['number'][0], themes[theme]['number'][1])
def error (error, debug=False) : if (debug) : print("ERROR: ",error) else : print(colorize("There's an error in the process, please config and try again", themes[theme]['error'][0], themes[theme]['error'][1]))
def test_colorize(self): string = 'lain' color.COLORED = True colored_string = color.colorize(string, 'cyan') self.assertNotEqual(string, colored_string, "Must be different")
def txt(str) : return colorize(str, themes[theme]['text'][0], themes[theme]['text'][1])