write yaml output and simplifies to better reading

This commit is contained in:
?ngel ?lvarez 2018-05-30 11:21:23 +02:00
parent 4bd8383b8d
commit 7c5e842f76

21
check
View file

@ -10,7 +10,7 @@ from trytond.transaction import Transaction
from trytond.pool import Pool
import logging
from lxml import etree
import pprint
import yaml
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
@ -28,6 +28,20 @@ pool.init()
context = {'company': 1}
try:
# Using LibYaml-based parser if available because it is much faster.
from yaml import CSafeDumper as SafeDumper
except ImportError:
from yaml import SafeDumper
def to_yaml(obj, output_file, padding=None, separator=None):
res = yaml.dump(obj, output_file, Dumper=SafeDumper, default_flow_style=False)
if padding:
res = '\n'.join([padding + x for x in
res.splitlines()])
if separator:
res = separator.join(res.splitlines())
return res
def download_fields_view_get():
'''
@ -37,7 +51,6 @@ def download_fields_view_get():
version = '4.8'
filename = "%s_%s"%(dbname, version)
log_file = open(filename, 'w')
pp = pprint.PrettyPrinter(depth=2, stream=log_file)
with Transaction().start(dbname, 1):
View = pool.get('ir.ui.view')
views = View.search([
@ -64,7 +77,9 @@ def download_fields_view_get():
r = res.copy()
del r['arch']
pp.pprint(r)
r['fields'] = r['fields'].keys()
to_yaml(r, log_file)
def check_data():