Initial import from Docker volume

This commit is contained in:
root
2025-12-26 13:11:43 +00:00
commit 4998dc066a
13336 changed files with 1767801 additions and 0 deletions

34
model/descriptors.py Executable file
View File

@@ -0,0 +1,34 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import functools
class dualmethod(object):
"""Descriptor implementing combination of class and instance method
When called on an instance, the class is passed as the first argument and a
list with the instance as the second.
When called on a class, the class itsefl is passed as the first argument.
>>> class Example(object):
... @dualmethod
... def method(cls, instances):
... print(len(instances))
...
>>> Example.method([Example()])
1
>>> Example().method()
1
"""
def __init__(self, func):
self.func = func
def __get__(self, instance, owner):
@functools.wraps(self.func)
def newfunc(*args, **kwargs):
if instance:
return self.func(owner, [instance], *args, **kwargs)
else:
return self.func(owner, *args, **kwargs)
return newfunc