我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用colorama.Fore.LIGHTYELLOW_EX。
def live_score(desc): mid = match_id(desc) data = c.livescore(mid) score = {} score['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'], data['matchinfo']['mchdesc']) score['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(), data['matchinfo']['status']) score['bowling'] = data['bowling'] score['batting'] = data['batting'] text = '' text += Fore.LIGHTYELLOW_EX + score['matchinfo'] + '\n' + score['status'] + '\n\n' text += Fore.BLUE + score['batting']['team'] + '\n' + Fore.BLACK for scr in reversed(score['batting']['score']): text += "{} :- {}/{} in {} overs\n".format(scr['desc'], scr['runs'], scr['wickets'], scr['overs']) for b in reversed(score['batting']['batsman']): text += "{} : {}({}) \n".format(b['name'].strip('*'), b['runs'], b['balls']) text += Fore.BLUE + "\n" + score['bowling']['team'] + '\n' + Fore.BLACK for scr in reversed(score['bowling']['score']): text += "{} :- {}/{} in {} overs\n".format(scr['desc'], scr['runs'], scr['wickets'], scr['overs']) for b in reversed(score['bowling']['bowler']): text += "{} : {}/{} \n".format(b['name'].strip('*'), b['wickets'], b['runs']) text += Fore.RESET return text
def process_ele(self, reddit_element): """ Accepts a RedditElement of Post/Comment details, then runs through the Handlers loaded from the other directory, attempting to download the url. """ print('%i/%i: ' % (self.loader.count_completed()+1, self.loader.count_total() ), end='') stringutil.print_color(Fore.LIGHTYELLOW_EX, stringutil.out("[%s](%s): %s" % (reddit_element.type, reddit_element.subreddit, reddit_element.title), False)) for url in reddit_element.get_urls(): print('\tURL: %s' % url) file = self.loader.url_exists(url) if file: stringutil.print_color(Fore.GREEN, "\t\t+URL already taken care of.") reddit_element.add_file(url, file) continue if self.manifest: skip, file = self.manifest.url_completed(url) if skip and (file is None or os.path.exists(file)): stringutil.print_color(Fore.GREEN, "\t\t+URL already handled in previous run.") reddit_element.add_file(url, file) if file is not None: hashjar.add_hash(file) # Add the existing file hash so we can deduplicate against it. continue base_file, file_info = self.build_file_info(reddit_element)# Build the file information array using this RedditElement's information file_path = self.process_url(url, file_info) reddit_element.add_file(url, self.check_duplicates(file_path)) #
def filter(self, record): record.spent = record.relativeCreated // 1000 if iswindows: record.fg = '' elif record.levelname == 'DEBG': record.fg = Fore.LIGHTBLACK_EX elif record.levelname == 'INFO': record.fg = Fore.LIGHTWHITE_EX elif record.levelname == 'WARN': record.fg = Fore.LIGHTYELLOW_EX elif record.levelname == 'ERR ': record.fg = Fore.LIGHTRED_EX elif record.levelname == 'CRIT': record.fg = Fore.RED else: record.fg = Fore.LIGHTWHITE_EX return True
def commentary(desc): mid = match_id(desc) data = c.commentary(mid) comm = {} comm['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'], data['matchinfo']['mchdesc']) comm['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(), data['matchinfo']['status']) comm['commentary'] = data['commentary'] text = '' text += Fore.LIGHTYELLOW_EX + comm['matchinfo'] + '\n' + comm['status'] + '\n\n' + Fore.RESET for com in comm['commentary']: text += "{}\n\n".format(com) return text
def scorecard(desc): mid = match_id(desc) data = c.scorecard(mid) card = {} card['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'], data['matchinfo']['mchdesc']) card['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(), data['matchinfo']['status']) card['scorecard'] = data['scorecard'] text = '' text += Fore.LIGHTYELLOW_EX + card['matchinfo'] + '\n' + card['status'] + '\n\n' text += Fore.BLACK + '*' * 35 + '\n\n' for scr in reversed(card['scorecard']): text += Fore.LIGHTYELLOW_EX + "{} {}\n{}/{} in {} overs\n\n".format(scr['batteam'], scr['inngdesc'], scr['runs'], scr['wickets'], scr['overs']) text += Fore.BLUE + "Batting\n" text += Fore.RED + "{:<17} {:<3} {:<3} {:<3} {}\n\n".format('Name', 'R', 'B', '4', '6') for b in scr['batcard']: text += Fore.BLACK + "{:<17} {:<3} {:<3} {:<3} {}\n{}\n\n".format(b['name'], b['runs'], b['balls'], b['fours'], b['six'], b['dismissal']) text += Fore.LIGHTYELLOW_EX + "-" * 35 + "\n\n" text += Fore.BLUE + "Bowling\n" text += Fore.RED + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format('Name', 'O', 'M', 'R', 'W') for b in scr['bowlcard']: text += Fore.BLACK + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(b['name'], b['overs'], b['maidens'], b['runs'], b['wickets']) text += Fore.BLUE + '*' * 35 + '\n\n' return text
def __init__(self): self.colors = {'red':Fore.RED,'green':Fore.GREEN,'cyan':Fore.CYAN,'yellow':Fore.LIGHTYELLOW_EX,'magenta':Fore.MAGENTA,'bold':Style.BRIGHT,'reset':Style.RESET_ALL} self.translator = Translator() self.select_languages = "tr" self.database = "dictionary.db" self.connection = sqlite3.connect(self.database) self.cursor = self.connection.cursor() self.columns = {'isim':'i_anlam','fiil':'f_anlam','zarf':'z_anlam','edat':'e_anlam','baglac':'b_anlam','sifat':'s_anlam','zamir':'zz_anlam'} self.names2 = {'isim':'isim','zarf':'zarf','ba?laç':'baglac','s?fat':'sifat','zamir':'zamir','fiil':'fiil','edat':'edat'} self.c_word = "" self.c_word_last = "" self.c_word_new = ""
def info_format(print_type, text): # info, prompt, alert, sleep lb = '{0}[{1}'.format(Fore.LIGHTGREEN_EX, Style.RESET_ALL) rb = '{0}]{1}'.format(Fore.LIGHTGREEN_EX, Style.RESET_ALL) new_text = Fore.LIGHTWHITE_EX + text + Style.RESET_ALL if print_type == 'info': return '{0}{1}*{2}{3} {4}'.format(lb, Fore.LIGHTGREEN_EX, Style.RESET_ALL, rb, new_text) elif print_type == 'prompt': return '{0}{1}${2}{3} {4}'.format(lb, Fore.LIGHTYELLOW_EX, Style.RESET_ALL, rb, new_text) elif print_type == 'alert': return '{0}{1}!{2}{3} {4}'.format(lb, Fore.LIGHTRED_EX, Style.RESET_ALL, rb, new_text) elif print_type == 'sleep': return '{0}-{1} {2}'.format(lb, rb, new_text)
def parse_alert_short(raw_alert, quiet, customer_name=None, color=True): """""" if color is True: yellow = Fore.LIGHTYELLOW_EX green = Fore.LIGHTGREEN_EX red = Fore.LIGHTRED_EX reset = Style.RESET_ALL else: yellow = '' green = '' red = '' reset = '' try: alert = enum_alert(raw_alert) alert_str = '' alert_cust_name = alert.get('customer_name') alert_host = alert.get('hostname') alert_severity = alert.get('max_severity_displayname') alert_reason = alert.get('scenario') alert_time = alert.get('timestamp') alert_status = alert.get('status') #alert_str += '{8} {4}{9}{6} - {0}{1}{6} alert on {2}{3}{6} for {4}{5}{6} ({7})!'.format( # Fore.LIGHTYELLOW_EX, alert_severity, Fore.LIGHTGREEN_EX, alert_host, Fore.LIGHTRED_EX, alert_reason, # Style.RESET_ALL, alert_time, alert_status.upper().replace('_', '-'), alert_cust_name) alert_str += '{8} {4}{9}{6} - {0}{1}{6} alert on {2}{3}{6} for {4}{5}{6} ({7})!'.format( yellow, alert_severity, green, alert_host, red, alert_reason, reset, alert_time, alert_status.upper().replace('_', '-'), alert_cust_name) return alert_str except Exception: # KeyError: if not quiet: return info_format('alert', 'There was an issue retrieving alerts for {0}. Skipping...'.format(customer_name))
def _report_created(self): # set up the report data rows = [] ips = [] data_center = self._get_data_center().get('ABBR') plan = self._get_plan().get('RAM') for linode in self._created_linodes: rows.append(( linode['hostname'], linode['public'], linode['private'], linode['gateway'], data_center, plan )) ips.append(linode['public']) firewall_command = './apply-firewall.py --private-key /path/to/key/deis --hosts ' + string.join(ips, ' ') # set up the report constants divider = Style.BRIGHT + Fore.MAGENTA + ('=' * 109) + Fore.RESET + Style.RESET_ALL column_format = " {:<20} {:<20} {:<20} {:<20} {:<12} {:>8}" formatted_header = column_format.format(*('HOSTNAME', 'PUBLIC IP', 'PRIVATE IP', 'GATEWAY', 'DC', 'PLAN')) # display the report print('') print(divider) print(divider) print('') print(Style.BRIGHT + Fore.LIGHTGREEN_EX + ' Successfully provisioned ' + str(self.num_nodes) + ' nodes!' + Fore.RESET + Style.RESET_ALL) print('') print(Style.BRIGHT + Fore.CYAN + formatted_header + Fore.RESET + Style.RESET_ALL) for row in rows: print(Fore.CYAN + column_format.format(*row) + Fore.RESET) print('') print('') print(Fore.LIGHTYELLOW_EX + ' Finish up your installation by securing your cluster with the following command:' + Fore.RESET) print('') print(' ' + firewall_command) print('') print(divider) print(divider) print('')