本文整理汇总了Python中prompt_toolkit.HTML属性的典型用法代码示例。如果您正苦于以下问题:Python prompt_toolkit.HTML属性的具体用法?Python prompt_toolkit.HTML怎么用?Python prompt_toolkit.HTML使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类prompt_toolkit
的用法示例。
在下文中一共展示了prompt_toolkit.HTML属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_suggested_additions
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def print_suggested_additions(self):
""" Prints a collection of suggested additions to the stdout. """
sys.stdout.flush()
sys.stderr.flush()
# Create a quick printing shortcut.
print_html = lambda data : print_formatted_text(HTML(data))
# Header.
print_html("")
print_html("<b><u>Automatic Suggestions</u></b>")
print_html("These suggestions are based on simple observed behavior;")
print_html("not all of these suggestions may be useful / desireable.")
print_html("")
self._print_suggested_requests()
print_html("")
#
# Backend helpers.
#
示例2: _show_range_packets
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def _show_range_packets(self, packets, limit):
msg = "--show more-- (press q to exit)"
count = 0
for p in packets:
count += 1
if count == limit:
count = 0
print_formatted_text(HTML(f"<jj bg='ansiyellow'>{msg}</jj>"), end="")
res = readchar.readchar()
# Deletes the last line
print("\033[A")
print(" "*len(msg))
print("\033[A")
if res.lower() == "q":
print("")
return
p.show()
示例3: _print_options
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def _print_options(self):
print_formatted_text(HTML(f"<{ColorSelected().theme.accent}> Options (Field = Value)</{ColorSelected().theme.accent}>"))
print (" -----------------------")
flag = True
options_aux = self.get_options()
if not len(options_aux):
print_info(" No options to configure")
return
for key, option in options_aux.items():
if flag:
print (" |")
flag = False
# Parameter is mandataroy
if option.required:
self._print_mandatory_option(key, option)
# Parameter is optional
else:
self._print_optional_option(key, option)
print ("\n")
示例4: prompt
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def prompt(commands, module=None):
"""Launch the prompt with the given commands
Args:
commands ([str]): List of commands to autocomplete
module (str, optional): Name of the module. Defaults to None.
Returns:
prompt session: Session of the promt
"""
default_prompt = "homePwn"
color_default_prompt = ColorSelected().theme.primary
warn = ColorSelected().theme.warn
confirm = ColorSelected().theme.confirm
html = HTML(f"<bold><{color_default_prompt}>{default_prompt} >></{color_default_prompt}></bold>")
if module:
html = HTML(f"<bold><{color_default_prompt}>{default_prompt}</{color_default_prompt}> (<{warn}>{module}</{warn}>) <{confirm}>>></{confirm}></bold> ")
data = session.prompt(
html,
completer= CustomCompleter(commands),
complete_style=CompleteStyle.READLINE_LIKE,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True)
return data
示例5: show_tasks
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def show_tasks(self):
if not len(self.tasks):
print_info("There are no running tasks at this time")
return
print_formatted_text(HTML(f'''
<ansiyellow> Index (Thread)</ansiyellow>
-------------------------'''))
flag = 0
for key, value in self.tasks.items():
pid = value.get("pid", "")
if not pid:
pid = ""
flag += 1
alive = "Alive" if value['thread'].is_alive() else "Death"
if flag > 1:
print (" |")
print(f" |_ {key} = {value['thread'].name} {pid} ({alive})")
print("")
示例6: display_qr
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def display_qr(qr_read, verbose):
"""QR util method to display
Args:
qr_read ([Reg]): Data of the qr read
verbose (Boolean): To display mor info
"""
color = ColorSelected().theme.confirm
print(color)
print_ok_raw(f"Found {len(qr_read)} registries")
for idx, reg in enumerate(qr_read):
print_info(f"==== Reg {idx} ====")
print_formatted_text(HTML(f"<{color}>Data:</{color}> {reg.data}"))
if(verbose):
print_formatted_text(HTML(f"<{color}>Type:</{color}> {reg.type}"))
print_formatted_text(HTML(f"<{color}>Rect:</{color}> {reg.rect}"))
print_formatted_text(HTML(f"<{color}>Polygon:</{color}> {reg.polygon}"))
示例7: select_profile
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def select_profile(profile_list):
selection = await radiolist_dialog(
title="Select AnyConnect profile",
text=HTML(
"The following AnyConnect profiles are detected.\n"
"The selection will be <b>saved</b> and not asked again unless the <pre>--profile-selector</pre> command line option is used"
),
values=[(p, p.name) for i, p in enumerate(profile_list)],
).run_async()
asyncio.get_event_loop().remove_signal_handler(signal.SIGWINCH)
if not selection:
return selection
logger.info("Selected profile", profile=selection.name)
return selection
示例8: list_servers
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def list_servers(self):
"""List the daemons users."""
servers = self.ctl.ListServers()
print("pantalaimon servers:")
for server, server_users in servers.items():
server_c = get_color(server)
print_formatted_text(HTML(f" - Name: <{server_c}>{server}</{server_c}>"))
user_list = []
for user, device in server_users:
user_c = get_color(user)
device_c = get_color(device)
user_list.append(
f" - <{user_c}>{user}</{user_c}> "
f"<{device_c}>{device}</{device_c}>"
)
if user_list:
print(" - Pan users:")
user_string = "\n".join(user_list)
print_formatted_text(HTML(user_string))
示例9: list_devices
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def list_devices(self, args):
devices = self.devices.ListUserDevices(args.pan_user, args.user_id)
print_formatted_text(HTML(f"Devices for user <b>{args.user_id}</b>:"))
for device in devices:
if device["trust_state"] == "verified":
trust_state = "<ansigreen>Verified</ansigreen>"
elif device["trust_state"] == "blacklisted":
trust_state = "<ansired>Blacklisted</ansired>"
elif device["trust_state"] == "ignored":
trust_state = "Ignored"
else:
trust_state = "Unset"
key = partition_key(device["ed25519"])
color = get_color(device["device_id"])
print_formatted_text(
HTML(
f" - Display name: "
f"{device['device_display_name']}\n"
f" - Device id: "
f"<{color}>{device['device_id']}</{color}>\n"
f" - Device key: "
f"<ansiyellow>{key}</ansiyellow>\n"
f" - Trust state: "
f"{trust_state}"
)
)
示例10: run
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def run(self):
"""Runs the interface and waits for user input commands."""
completer = WordCompleter(['show', 'name', 'field', 'fields',
'dump', 'recalculate', 'clear', 'back'])
history = FileHistory(self._polym_path + '/.linterface_history')
session = PromptSession(history=history)
while True:
try:
command = session.prompt(HTML("<bold>PH:cap/t%d/<red>%s</red> > </bold>" %
(self._tindex, self._l.name)),
completer=completer,
complete_style=CompleteStyle.READLINE_LIKE,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True)
except KeyboardInterrupt:
self.exit_program()
continue
# Argument parsing
command = command.split(" ")
if command[0] in self.EXIT:
self.exit_program()
elif command[0] in self.RET:
break
elif command[0] in ["s", "show"]:
self._show(command)
elif command[0] == "name":
self._name(command)
elif command[0] in ["field", "f"]:
self._field(command)
elif command[0] in ["fields", "fs"]:
self._fields(command)
elif command[0] in ["dump", "d"]:
self._dump(command)
elif command[0] in ["recalculate", "r"]:
self._recalculate(command)
elif command[0] == "clear":
Interface._clear()
elif command[0] == "":
continue
else:
Interface._wrong_command()
示例11: run
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def run(self):
"""Runs the interface and waits for user input commands."""
completer = WordCompleter(['show', 'dissect', 'template', 'wireshark',
'clear', 'back'])
history = FileHistory(self._polym_path + '/.tlinterface_history')
session = PromptSession(history=history)
while True:
try:
command = session.prompt(HTML("<bold>PH:<red>cap</red> > </bold>"),
completer=completer,
complete_style=CompleteStyle.READLINE_LIKE,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True)
except KeyboardInterrupt:
self.exit_program()
continue
command = command.split(" ")
if command[0] in self.EXIT:
self.exit_program()
elif command[0] in self.RET:
break
elif command[0] in ["show", "s"]:
self._show(command)
elif command[0] == "dissect":
self._dissect(command)
elif command[0] in ["template", "t"]:
self._template(command)
elif command[0] in ["wireshark", "w"]:
self._wireshark(command)
elif command[0] == "clear":
Interface._clear()
elif command[0] == "":
continue
else:
Interface._wrong_command()
示例12: run
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def run(self):
"""Runs the interface and waits for user input commands."""
completer = WordCompleter(['capture', 'spoof', 'clear', 'import'])
history = FileHistory(self._polym_path + '/.minterface_history')
session = PromptSession(history=history)
while True:
try:
command = session.prompt(HTML("<bold><red>PH</red> > </bold>"),
completer=completer,
complete_style=CompleteStyle.READLINE_LIKE,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True)
except KeyboardInterrupt:
self.exit_program()
continue
command = command.split(" ")
if command[0] in self.EXIT:
self.exit_program()
elif command[0] in ["capture", "c"]:
self._capture(command)
elif command[0] in ["spoof", "s"]:
self._spoof(command)
elif command[0] in ["import", "i"]:
self._import(command)
elif command[0] == "clear":
Interface._clear()
elif command[0] == "":
continue
else:
Interface._wrong_command()
示例13: _print_mandatory_option
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def _print_mandatory_option(self, key, option):
if str(option.value) == "None":
print_formatted_text(HTML(f''' |_[<{ColorSelected().theme.warn}>REQUIRED</{ColorSelected().theme.warn}>] \
{key} = <{ColorSelected().theme.confirm}>{option.value}</{ColorSelected().theme.confirm}> ({option.description})'''))
else:
print_formatted_text(HTML(f''' |_{key} = <{ColorSelected().theme.confirm}>{option.value} </{ColorSelected().theme.confirm}> ({option.description})'''))
示例14: _print_optional_option
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def _print_optional_option(self, key, option):
if str(option.value) == "None":
print_formatted_text(HTML(f" |_[OPTIONAL] {key} = <{ColorSelected().theme.confirm}>{option.value}</{ColorSelected().theme.confirm}> ({option.description})"))
else:
print_formatted_text(HTML(f" |_{key} = <{ColorSelected().theme.confirm}>{option.value}</{ColorSelected().theme.confirm}> ({option.description})"))
示例15: _print_info
# 需要导入模块: import prompt_toolkit [as 别名]
# 或者: from prompt_toolkit import HTML [as 别名]
def _print_info(self):
print_formatted_text(HTML(f"<{ColorSelected().theme.accent}>Module Info</{ColorSelected().theme.accent}>"))
print("===========")
for key, value in self.get_info().items():
print_formatted_text(HTML(f"<{ColorSelected().theme.accent}> {key}</{ColorSelected().theme.accent}>"))
print (' ' + '-' * len(key))
print (f" |_{value}\n")