Files
tryton/trytond/tools/__init__.py
T
Maxime Richez d64ae06e19 Add summary to line list
A function field summary is added which takes the first line of description
field. This is useful to identify line without product (only with description)
in the list.

issue9695
review292431002
2020-12-25 17:14:57 +01:00

35 lines
1.2 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
try:
from functools import cached_property
except ImportError:
from werkzeug.utils import cached_property
from .misc import (
file_open, get_smtp_server, reduce_ids, reduce_domain,
grouped_slice, is_instance_method, resolve, strip_wildcard,
lstrip_wildcard, rstrip_wildcard, slugify, sortable_values,
escape_wildcard, sql_pairing, firstline)
from .decimal_ import decistmt
__all__ = ['file_open', 'get_smtp_server', 'reduce_ids',
'reduce_domain', 'grouped_slice', 'is_instance_method', 'resolve',
'strip_wildcard', 'lstrip_wildcard', 'rstrip_wildcard', 'slugify',
'decistmt', 'ClassProperty', 'cursor_dict', 'cached_property',
'sortable_values', 'escape_wildcard', 'sql_pairing', 'firstline']
class ClassProperty(property):
def __get__(self, cls, owner):
return self.fget.__get__(None, owner)()
def cursor_dict(cursor, size=None):
size = cursor.arraysize if size is None else size
while True:
rows = cursor.fetchmany(size)
if not rows:
break
for row in rows:
yield {d[0]: v for d, v in zip(cursor.description, row)}