本文整理汇总了Python中pprint.pprint.pprint方法的典型用法代码示例。如果您正苦于以下问题:Python pprint.pprint方法的具体用法?Python pprint.pprint怎么用?Python pprint.pprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pprint.pprint
的用法示例。
在下文中一共展示了pprint.pprint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pprint
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def pprint(
self,
depth: int = None,
compact: bool = True,
**pprint_kwargs
) -> None:
"""
Pretty print the builtin representation of a model.
Parameters
----------
depth
number of levels printed, all levels printed by default
compact
combine items on the same line if they fit
pprint_kwargs
additional keyword arguments for ``pprint.pprint``
"""
pprint(self.asbuiltin(), depth=depth, compact=compact, **pprint_kwargs)
示例2: test_self_driver
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def test_self_driver():
d = adbutils.adb.device()
package_name = "com.xueqiu.android"
# package_name = "io.appium.android.apis"
d.forward("tcp:7912", "tcp:7912")
ret = requests.get(f"http://localhost:7912/proc/{package_name}/webview").json()
for data in ret:
pprint(data)
lport = d.forward_port("localabstract:"+data["socketPath"])
wd = WebviewDriver(f"http://localhost:{lport}")
tabs = wd.get_active_tab_list()
pprint(tabs)
for tab in tabs:
print(tab.current_url())
tab.click_by_xpath('//*[@id="phone-number"]')
tab.clear_text_by_xpath('//*[@id="phone-number"]')
tab.send_keys("123456789")
break
示例3: main
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--test", action="store_true", help="run test_self_driver")
args = parser.parse_args()
# WebviewDriver()
import uiautomator2 as u2
d = u2.connect_usb()
assert d._adb_device, "must connect with usb"
for socket_path in d.request_agent("/webviews").json():
port = d._adb_device.forward_port("localabstract:"+socket_path)
data = requests.get(f"http://localhost:{port}/json/version").json()
import pprint
pprint.pprint(data)
示例4: test
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def test():
r = Rect(10,10,200,50)
import pprint
pp = pprint.pprint
w = sys.stdout.write
w('a Rectangle: ')
pp(r.getProperties())
w('\nverifying...')
r.verify()
w(' OK\n')
#print 'setting rect.z = "spam"'
#r.z = 'spam'
w('deleting rect.width ')
del r.width
w('verifying...')
r.verify()
示例5: assertListEquals
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def assertListEquals(self, l1, l2, msg=None):
"""compares two lists
If the two list differ, the first difference is shown in the error
message
"""
_l1 = l1[:]
for i, value in enumerate(l2):
try:
if _l1[0] != value:
from pprint import pprint
pprint(l1)
pprint(l2)
self.fail('%r != %r for index %d' % (_l1[0], value, i))
del _l1[0]
except IndexError:
if msg is None:
msg = 'l1 has only %d elements, not %s (at least %r missing)'% (i, len(l2), value)
self.fail(msg)
if _l1:
if msg is None:
msg = 'l2 is lacking %r' % _l1
self.fail(msg)
示例6: read
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def read(filename, createTree=True):
doc = etree.parse(filename)
root = doc.getroot()
root.get('name')
root.get('StandardName')
tolower(root)
rootNode = root.find('./robotnode[@name="%s"]' % root.get('RootNode'))
return parse(rootNode, root)
# if __name__ == "__main__":
# import sys, pprint
# print(sys.argv[1])
# structure = read(sys.argv[1],False)
# pprint.pprint(structure)
# pass
示例7: test
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def test():
r = Rect(10,10,200,50)
import pprint
pp = pprint.pprint
print 'a Rectangle:'
pp(r.getProperties())
print
print 'verifying...',
r.verify()
print 'OK'
#print 'setting rect.z = "spam"'
#r.z = 'spam'
print 'deleting rect.width'
del r.width
print 'verifying...',
r.verify()
示例8: show
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def show(self):
from ckan.lib.search import show
if not len(self.args) == 2:
print 'Missing parameter: dataset-name'
return
index = show(self.args[1])
pprint(index)
示例9: add
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def add(self):
import ckan.model as model
if len(self.args) < 2:
print 'Need name of the user.'
sys.exit(1)
username = self.args[1]
# parse args into data_dict
data_dict = {'name': username}
for arg in self.args[2:]:
try:
field, value = arg.split('=', 1)
data_dict[field] = value
except ValueError:
raise ValueError('Could not parse arg: %r (expected "<option>=<value>)"' % arg)
if 'password' not in data_dict:
data_dict['password'] = self.password_prompt()
if 'fullname' in data_dict:
data_dict['fullname'] = data_dict['fullname'].decode(sys.getfilesystemencoding())
print('Creating user: %r' % username)
try:
import ckan.logic as logic
site_user = logic.get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
context = {
'model': model,
'session': model.Session,
'ignore_auth': True,
'user': site_user['name'],
}
user_dict = logic.get_action('user_create')(context, data_dict)
pprint(user_dict)
except logic.ValidationError, e:
print e
sys.exit(1)
示例10: runtest
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def runtest():
import uiautomator2 as u2
d = u2.connect_usb()
pprint(d.request_agent("/webviews").json())
port = d._adb_device.forward_port("localabstract:chrome_devtools_remote")
wd = WebviewDriver(f"http://localhost:{port}")
tabs = wd.get_active_tab_list()
pprint(tabs)
示例11: loadTestsFromName
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def loadTestsFromName(self, name, module=None):
parts = name.split('.')
if module is None or len(parts) > 2:
# let the base class do its job here
return [super(NonStrictTestLoader, self).loadTestsFromName(name)]
tests = self._collect_tests(module)
# import pprint
# pprint.pprint(tests)
collected = []
if len(parts) == 1:
pattern = parts[0]
if callable(getattr(module, pattern, None)) and pattern not in tests:
# consider it as a suite
return self.loadTestsFromSuite(module, pattern)
if pattern in tests:
# case python unittest_foo.py MyTestTC
klass, methodnames = tests[pattern]
for methodname in methodnames:
collected = [klass(methodname) for methodname in methodnames]
else:
# case python unittest_foo.py something
for klass, methodnames in list(tests.values()):
collected += [klass(methodname) for methodname in methodnames]
elif len(parts) == 2:
# case "MyClass.test_1"
classname, pattern = parts
klass, methodnames = tests.get(classname, (None, []))
for methodname in methodnames:
collected = [klass(methodname) for methodname in methodnames]
return collected
示例12: report
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def report(self, f):
import pprint
pprint.pprint(self.__dict__, f)
示例13: infoBoxParser
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def infoBoxParser(text):
t = ''
infob = [x for x in re.finditer(infobStartRegEx, text)]
infobs = []
if infob:
for i in infob:
start = i.start()
infobContent, end = bSB(text[start:], openDelim='{', closeDelim='}')
#print('Infobox:', text[start:end])
infobContent = clean.sub('', infobContent)
t += text[:start]+text[end+start:]
if infobContent:
infobContent = infobContent.replace('[', '').replace(']', '').splitlines() #.replace('|', '').split('\n'))
infobDict = {}
for line in infobContent:
line = line.strip('| ').strip(' ')
line = line.split('=')
if len(line) == 2:
if line[0] and line[1]:
l = line[1].strip('[').strip(']').strip()
if '|' in l:
l = l.split('|')[1]
infobDict[line[0].strip()]= l
infobs.append(infobDict)
return t, infobs
#pprint.pprint(infobDict)
示例14: printContents
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def printContents(omexPath):
""" Prints contents of archive.
:param omexPath:
:return:
"""
pprint.pprint(listContents(omexPath))
示例15: __init__
# 需要导入模块: from pprint import pprint [as 别名]
# 或者: from pprint.pprint import pprint [as 别名]
def __init__(self):
self.base = 'http://www.sbs.com.au/ondemand/'
self.main_txt = re.sub(r'^[^=]+=','', geturl(self.base + 'js/video-menu'))
self.main = jsonc(self.main_txt)
if 0:
import pprint
pprint.pprint(self.main)
self.cache = {}
self.cache[tuple([])] = {"url" : None, "children" : self.__menu([], self.main.values())}
print self.main