From 2958d3fa8e9a9ac530dd58f1c8adb97becc7c3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 13 Mar 2016 22:17:04 +0100 Subject: [PATCH 1/3] [FIX] reset permissions that should not have changed --- mis_builder/__openerp__.py | 0 mis_builder/models/accounting_none.py | 0 mis_builder/models/aep.py | 0 mis_builder/models/mis_builder.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 mis_builder/__openerp__.py mode change 100755 => 100644 mis_builder/models/accounting_none.py mode change 100755 => 100644 mis_builder/models/aep.py mode change 100755 => 100644 mis_builder/models/mis_builder.py diff --git a/mis_builder/__openerp__.py b/mis_builder/__openerp__.py old mode 100755 new mode 100644 diff --git a/mis_builder/models/accounting_none.py b/mis_builder/models/accounting_none.py old mode 100755 new mode 100644 diff --git a/mis_builder/models/aep.py b/mis_builder/models/aep.py old mode 100755 new mode 100644 diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py old mode 100755 new mode 100644 From 9b626fe5daa27c9e02ac8e4683671475f20a5b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 13 Mar 2016 22:19:41 +0100 Subject: [PATCH 2/3] [IMP] improve AccountingNone wrt comparisons mainly --- mis_builder/models/accounting_none.py | 67 ++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/mis_builder/models/accounting_none.py b/mis_builder/models/accounting_none.py index bcf15ecb..8986ed41 100644 --- a/mis_builder/models/accounting_none.py +++ b/mis_builder/models/accounting_none.py @@ -5,7 +5,8 @@ Provides the AccountingNone singleton AccountingNone is a null value that dissolves in basic arithmetic operations, -as illustrated in the examples below +as illustrated in the examples below. In comparisons, AccountingNone behaves +the same as zero. >>> 1 + 1 2 @@ -51,6 +52,34 @@ AccountingNone AccountingNone >>> AccountingNone * None AccountingNone +>>> None * AccountingNone +AccountingNone +>>> str(AccountingNone) +'' +>>> bool(AccountingNone) +False +>>> AccountingNone > 0 +False +>>> AccountingNone < 0 +False +>>> AccountingNone < 1 +True +>>> AccountingNone > 1 +False +>>> 0 < AccountingNone +False +>>> 0 > AccountingNone +False +>>> 1 < AccountingNone +False +>>> 1 > AccountingNone +True +>>> AccountingNone == 0 +True +>>> AccountingNone == 0.0 +True +>>> AccountingNone == None +True """ @@ -89,10 +118,15 @@ class AccountingNoneType(object): def __neg__(self): return self + def __div__(self, other): + if other is AccountingNone: + return AccountingNone + return 0.0 + + def __rdiv__(self, other): + raise ZeroDivisionError + def __floordiv__(self, other): - """ - Overload of the // operator - """ if other is AccountingNone: return AccountingNone return 0.0 @@ -101,9 +135,6 @@ class AccountingNoneType(object): raise ZeroDivisionError def __truediv__(self, other): - """ - Overload of the / operator - """ if other is AccountingNone: return AccountingNone return 0.0 @@ -116,17 +147,29 @@ class AccountingNoneType(object): return AccountingNone return 0.0 - def __rmul__(self, other): - if other is None or other is AccountingNone: - return AccountingNone - return 0.0 + __rmul__ = __mul__ def __repr__(self): return 'AccountingNone' - def __unicode__(self): + def __str__(self): return '' + def __nonzero__(self): + return False + + def __bool__(self): + return False + + def __eq__(self, other): + return other == 0 or other is None or other is AccountingNone + + def __lt__(self, other): + return 0 < other + + def __gt__(self, other): + return 0 > other + AccountingNone = AccountingNoneType() From fe4fa678fb52c5efc0dceb96df7a85eec28645ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 13 Mar 2016 22:56:39 +0100 Subject: [PATCH 3/3] Add copyright header and __all__ to accounting_none.py --- mis_builder/models/accounting_none.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mis_builder/models/accounting_none.py b/mis_builder/models/accounting_none.py index 8986ed41..57f7f549 100644 --- a/mis_builder/models/accounting_none.py +++ b/mis_builder/models/accounting_none.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- - - +# © 2016 Thomas Binsfeld +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). """ -Provides the AccountingNone singleton +Provides the AccountingNone singleton. AccountingNone is a null value that dissolves in basic arithmetic operations, as illustrated in the examples below. In comparisons, AccountingNone behaves @@ -82,6 +83,8 @@ True True """ +__all__ = ['AccountingNone'] + class AccountingNoneType(object):