當前位置: 首頁>>代碼示例>>Python>>正文


Python colors.color方法代碼示例

本文整理匯總了Python中colors.color方法的典型用法代碼示例。如果您正苦於以下問題:Python colors.color方法的具體用法?Python colors.color怎麽用?Python colors.color使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在colors的用法示例。


在下文中一共展示了colors.color方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: clarify_expression_value

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def clarify_expression_value(expression_value, expression_type, color):
	debug_print(3, 'clarify_value expression_value=', expression_value)
	
	if expression_type == 'char':
		m = re.match(r"^(-?\d+) '(.*)'$", expression_value)
		if m:
			ascii = int(m.group(1))
			if (0 < ascii < 9) or (13 < ascii < 32)	 or (ascii == 127):
				 expression_value = '%d (non-printable ASCII character)' % ascii
			elif ascii < 0 or ascii > 128:
				 expression_value = '%d (not valid ASCII)' % ascii
			elif ascii == 0:
				 expression_value = "0 = '\\0'"
			else:
				 expression_value = "%s = '%s'" % m.groups()
	return clarify_values(expression_value, color)
	
# transform value into something a novice programmer more likely to understand 
開發者ID:COMP1511UNSW,項目名稱:dcc,代碼行數:20,代碼來源:drive_gdb.py

示例2: main

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def main():
    node = Node(node_name="py@127.0.0.1", cookie="COOKIE")
    event_loop = node.get_loop()

    #
    # 1. At the same time as P1 (they should not interfere) create a process P2
    #   Send a message to process example7 on the Erlang node with "test_monitor"
    #   command. This will spawn an Erlang process and tell us the pid.
    #   Reply from Erlang node will trigger next steps above in ExampleProcess6
    #
    proc = MonitorExample7()

    LOG.info("Sending {example7, test_monitor, %s} to remote 'example7'" % proc.pid_)
    remote_receiver_name = (Atom('erl@127.0.0.1'), Atom("example7"))
    send_task = node.send(sender=proc.pid_,
                          receiver=remote_receiver_name,
                          message=(Atom("example7"),
                                   Atom("test_monitor"),
                                   proc.pid_))

    sleep_sec = 5
    LOG.info("Sleep %d sec" % sleep_sec)

    #
    # 3. End, sending a stop message
    #
    def stop_task():
        LOG.info(color("Stopping remote loop", fg="red"))
        node.send_nowait(sender=proc.pid_, receiver=remote_receiver_name,
                         message=(Atom("example7"), Atom("stop")))

    def destroy_task():
        LOG.error("Destroying")
        node.destroy()
        LOG.error("Done")

    event_loop.create_task(send_task)
    event_loop.call_later(sleep_sec, stop_task)
    event_loop.call_later(2 * sleep_sec, destroy_task)
    node.run() 
開發者ID:Pyrlang,項目名稱:Pyrlang,代碼行數:42,代碼來源:e07_py_monitor_erlang.py

示例3: main

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def main():
    node = Node(node_name="py@127.0.0.1", cookie="COOKIE")
    event_loop = node.get_loop()

    #
    # 1. Create a process P1
    #   Send a message to process example6 on the Erlang node with "test_link"
    #   command. This will spawn an Erlang process and tell us the pid.
    #   Reply from Erlang node will trigger next steps above in ExampleProcess6
    #
    p1 = LinkExample6()

    LOG.info("Sending {example6, test_link, %s} to remote 'example6'" % p1.pid_)
    remote_receiver_name = (Atom('erl@127.0.0.1'), Atom("example6"))

    def send_task():
        node.send_nowait(sender=p1.pid_,
                         receiver=remote_receiver_name,
                         message=(Atom("example6"), Atom("test_link"), p1.pid_))

    sleep_sec = 5
    LOG.info("Sleep %d sec" % sleep_sec)

    #
    # 3. End, sending a stop message
    #
    def task_sleep1():
        LOG.info(color("Stopping remote loop", fg="red"))
        node.send_nowait(sender=p1.pid_,
                         receiver=remote_receiver_name,
                         message=(Atom("example6"), Atom("stop")))

    def task_sleep2():
        node.destroy()
        LOG.error("Done")

    event_loop.call_soon(send_task)
    event_loop.call_later(sleep_sec, task_sleep1)
    event_loop.call_later(2 * sleep_sec, task_sleep2)
    node.run() 
開發者ID:Pyrlang,項目名稱:Pyrlang,代碼行數:42,代碼來源:e06_py_link_erlang.py

示例4: exit

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def exit(self, reason=None):
        LOG.info("TestMonitorProcess: Received EXIT(%s)" % reason)
        node = self.get_node()
        #
        # 3. End, sending a stop message
        #
        LOG.info(color("Stopping erlang node", fg="red"))
        node.send_nowait(sender=self.pid_, receiver=remote_receiver_name(),
                         message=(Atom("example5"), Atom("stop")))
        LOG.error("Done")
        super().exit(reason) 
開發者ID:Pyrlang,項目名稱:Pyrlang,代碼行數:13,代碼來源:e05_erl_link_monitor_python.py

示例5: color_tag

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def color_tag(text):
        return color(text, fg=231, bg=239, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例6: color_next

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def color_next(text):
        return color(text, fg=231, bg=28, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例7: color_version

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def color_version(text):
        return color(text, fg=255, bg=25, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例8: color_promoted

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def color_promoted(text):
        return color(text, fg=255, bg=33, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例9: color_warn

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def color_warn(text):
        return color(text, fg=214, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例10: bold

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def bold(text):
        return color(text, style='bold') 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:4,代碼來源:termcolors.py

示例11: tag

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def tag(self, text):
        """
        Decorate the specified text with the TAG color class
        """
        return self.__decorate(text, color_tag) 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:7,代碼來源:termcolors.py

示例12: next

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def next(self, text):
        """
        Decorate the specified text with the NEXT color class
        """
        return self.__decorate(text, color_next) 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:7,代碼來源:termcolors.py

示例13: ver

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def ver(self, text):
        """
        Decorate the specified text with the VERSION color class
        """
        return self.__decorate(text, color_version) 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:7,代碼來源:termcolors.py

示例14: prom

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def prom(self, text):
        """
        Decorate the specified text with the PROMOTED color class
        """
        return self.__decorate(text, color_promoted) 
開發者ID:manuelbua,項目名稱:gitver,代碼行數:7,代碼來源:termcolors.py

示例15: watch_stdin_for_valgrind_errors

# 需要導入模塊: import colors [as 別名]
# 或者: from colors import color [as 別名]
def watch_stdin_for_valgrind_errors():
	colorize_output = sys.stderr.isatty() or os.environ.get('DCC_COLORIZE_OUTPUT', False)
	if colorize_output:
		color = colors.color
	else:
		color = lambda text, color_name: text
	debug_level = int(os.environ.get('DCC_DEBUG', '0'))
	while True:
		line = sys.stdin.readline()
		if not line:
			break
		if debug_level > 1: print('valgrind: ', line, file=sys.stderr)
		if 'vgdb me' in line:
			error = 'Runtime error: ' + color('uninitialized variable accessed', 'red') + '.'
			os.environ['DCC_VALGRIND_ERROR'] = error
			print('\n'+error, file=sys.stderr)
			sys.stderr.flush()
			start_gdb()
			sys.exit(0)
		elif 'loss record' in line:
			line = sys.stdin.readline()
			if 'malloc' in line:
				line = sys.stdin.readline()
				m = re.search(r'(\S+)\s*\((.+):(\d+)', line)
				if m:
					print('Error: free not called for memory allocated with malloc in function {} in {} at line {}.'.format(m.group(1),m.group(2),m.group(3)), file=sys.stderr)
				else:
					print('Error: free not called for memory allocated with malloc.', file=sys.stderr)
			else:
				print('Error: memory allocated not de-allocated.', file=sys.stderr)
			sys.exit(0) 
開發者ID:COMP1511UNSW,項目名稱:dcc,代碼行數:33,代碼來源:start_gdb.py


注:本文中的colors.color方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。