Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testMaxTableWidthIsTheLawWhenMinColumnWidthSetForSomeColumns(self):
max_width = 40
t = PrettyTable(max_table_width=max_width)
t.field_names = ['tag', 'versions']
versions = [
'python/django-appconf:1.0.1',
'python/django-braces:1.8.1',
'python/django-compressor:2.0',
'python/django-debug-toolbar:1.4',
'python/django-extensions:1.6.1',
]
t.add_row(['allmychanges.com', ', '.join(versions)])
# Now, we'll set min width for first column
# to not wrap it's content
t._min_width['tag'] = len('allmychanges.com')
result = t.get_string(hrules=ALL)
lines = result.strip().split('\n')
def run_tests(tests, log, config):
""" Run test wrapper."""
table = PrettyTable(['Test', 'Result'])
for test_name in tests:
if test_name == 'all':
for _, conf in UNIT_TESTS.iteritems():
test = conf['class'](conf['name'], log, config,
conf['bpfilter'],
count=conf['count'],
payload=conf['payload'],
local_sniff=conf['local_sniff'])
result = test.run()
table.add_row([conf['name'],
'Succeeded' if result else 'Failed'])
else:
conf = UNIT_TESTS[test_name]
test = conf['class'](conf['name'], log, config,
conf['bpfilter'],
count=conf['count'],
pp_warning(
"Please, specify module name, or function name. If both, separate with !\n")
return
param = line.split()[0]
mods = {}
# Get the base address for all the kernel modules
for m in api.get_module_list(0):
mods[m["fullname"].lower()] = m["base"]
# If process is set, get the base address for all the modules:
if self.proc_context is not None:
for m in api.get_module_list(self.proc_context.get_pgd()):
mods[m["fullname"].lower()] = m["base"]
t = PrettyTable(["Module", "Function", "Address"])
t.align["Address"] = "r"
for sym in self.find_syms(param):
t.add_row([sym["mod"], sym["name"], "%016x" % (sym["addr"] if sym["mod_fullname"].lower(
) not in mods else sym["addr"] + mods[sym["mod_fullname"].lower()])])
pp_print(str(t) + "\n")
gateway_mac_address: Union[None, str] = None
prefix: Union[None, str] = None
mtu: int = 1500
router_lifetime: int = 2
reachable_time: int = 2000
retrans_timer: int = 2000
advertisement_interval: int = 2000
# endregion
# region Set prefix
if ipv6_prefix is not None:
prefix = ipv6_prefix
# endregion
# region Set technique
technique_pretty_table: PrettyTable = PrettyTable([self._base.info_text('Index'),
self._base.info_text('ICMPv6 MiTM technique')])
for technique_key in self._techniques.keys():
technique_pretty_table.add_row([str(technique_key), self._techniques[technique_key]])
if technique is None:
self._base.print_info('ICMPv6 MiTM technique list:')
print(technique_pretty_table)
print(self._base.c_info + 'Select ICMPv6 MiTM technique index from range (1 - ' +
str(len(self._techniques.keys())) + '): ', end='')
current_technique_index: str = input()
assert current_technique_index.isdigit(), \
'ICMPv6 MiTM technique index is not digit!'
current_technique_index: int = int(current_technique_index)
assert not any([current_technique_index < 1, current_technique_index > len(self._techniques.keys())]), \
'ICMPv6 MiTM technique index is not within range (1 - ' + str(len(self._techniques.keys())) + ')'
self._technique_index = current_technique_index
self.parser.print_help()
return None
color = Color()
if (args.workspace_subcommand == "add"):
ws_name = slashes2dash(args.name)
self.ws.add(ws_name, args.path)
logger.info(color.colored(
"Workspace `%s` successfuly added" % ws_name, "green"))
elif (args.workspace_subcommand == "remove"):
ws_name = slashes2dash(args.name)
self.ws.remove(ws_name)
logger.info(color.colored(
"Workspace `%s` successfuly removed" % ws_name, "green"))
elif (args.workspace_subcommand == "list"):
table = PrettyTable(["Name", "Path"])
table.align["Name"] = "l"
table.align["Path"] = "l"
for key, ws in sorted(self.ws.list().items()):
table.add_row([key, ws["path"]])
logger.info(table)
tbl_Options.add_row([QApplication.translate('HelpDlg','Delete',None),QApplication.translate('HelpDlg','Deletes the selected alarm.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Copy Table',None),QApplication.translate('HelpDlg','Copy the alarm table in tab separated format to the clipboard. Option or ALT click to copy a tabular format to the clipboard.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','All On',None),QApplication.translate('HelpDlg','Enables all alarms.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','All Off',None),QApplication.translate('HelpDlg','Disables all alarms.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Load',None),QApplication.translate('HelpDlg','Load alarm definition from a file.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Save',None),QApplication.translate('HelpDlg','Save the alarm definitions to a file.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Clear',None),QApplication.translate('HelpDlg','Clears all alarms from the table.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Help',None),QApplication.translate('HelpDlg','Opens this window.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Load from Profile',None),QApplication.translate('HelpDlg','when ticked will replace the alarm table when loading a profile with the alarms stored in the profile. If there are no alarms in the profile the alarm table will be cleared.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','Load from Background',None),QApplication.translate('HelpDlg','when ticked will replace the alarm table when loading a background profile with the alarms stored in the profile. If there are no alarms in the profile the alarm table will be cleared.',None)])
tbl_Options.add_row([QApplication.translate('HelpDlg','PopUp TimeOut',None),QApplication.translate('HelpDlg','A PopUp will automatically close after this time if the OK button has not been clicked.',None)])
strlist.append(tbl_Options.get_html_string(attributes={"width":"100%","border":"1","padding":"1","border-collapse":"collapse"}))
strlist.append("<br><br><b>")
strlist.append(QApplication.translate('HelpDlg','Alarm Actions',None))
strlist.append("</b>")
tbl_Actionstop = prettytable.PrettyTable()
tbl_Actionstop.header = False
tbl_Actionstop.add_row([QApplication.translate('HelpDlg','Enter the Command into the Description field of the Alarm.',None)])
strlist.append(tbl_Actionstop.get_html_string(attributes={"width":"100%","border":"1","padding":"1","border-collapse":"collapse"}))
tbl_Actions = prettytable.PrettyTable()
tbl_Actions.field_names = [QApplication.translate('HelpDlg','Action',None),QApplication.translate('HelpDlg','Command',None),QApplication.translate('HelpDlg','Meaning',None)]
tbl_Actions.add_row([QApplication.translate('HelpDlg','Pop Up',None),QApplication.translate('HelpDlg','
def _format(self, title, key_values):
if len(key_values) == 0:
return ""
tbl = _PrettyTable(header=False)
for k, v in six.iteritems(key_values):
tbl.add_row([k, v])
tbl.align['Field 1'] = 'l'
tbl.align['Field 2'] = 'l'
s = title + ":\n"
s += tbl.__str__() + '\n'
return s
def listmultiparts(args):
vault_name = args.vault
region = args.region
glacierconn = glaciercorecalls.GlacierConnection(args.aws_access_key, args.aws_secret_key, region=region)
if check_vault_name(vault_name):
response = glaciercorecalls.GlacierVault(glacierconn, vault_name).list_multipart_uploads()
parse_response(response)
jdata = json.loads(response.read())
print "Marker: ", jdata['Marker']
if len(jdata['UploadsList']) > 0:
headers = sorted(jdata['UploadsList'][0].keys())
table = PrettyTable(headers)
for entry in jdata['UploadsList']:
table.add_row([locale.format('%d', entry[k], grouping=True) if k == 'PartSizeInBytes'
else entry[k] for k in headers ])
print table
def print_issues(data):
n = ["id","priority","status","title"]
n = [ i.upper() for i in n ]
table = prettytable.PrettyTable(n)
for issue in data["issues"]:
table.add_row([issue["id"],issue["priority"]["name"],issue["status"]["name"], issue["subject"]])
print(table)