コード例 #1
0
 def match(self, other):
     typecheck(other, Units)
     if self is not other:
         raise Units.Mismatch(
             'Units mismatch: {!r} vs {!r}',
             str(self),
             str(other),
         )
コード例 #2
0
ファイル: _value.py プロジェクト: nejucomo/dimana
    def __init__(self, spec, units=None):
        if units is None:
            (spec, units) = _parse_value(spec)

        typecheck(spec, Decimal)
        typecheck(units, Units)

        self.amount = spec
        self.units = units
コード例 #3
0
ファイル: _value.py プロジェクト: nejucomo/dimana
 def __div__(self, other):
     typecheck(other, Value)
     return Value(self.amount / other.amount, self.units / other.units)
コード例 #4
0
ファイル: _value.py プロジェクト: nejucomo/dimana
 def __mul__(self, other):
     typecheck(other, Value)
     return Value(self.amount * other.amount, self.units * other.units)
コード例 #5
0
ファイル: _value.py プロジェクト: nejucomo/dimana
    def __init__(self, decimal, units):
        typecheck(decimal, Decimal)
        typecheck(units, Units)

        self.amount = decimal
        self.units = units
コード例 #6
0
ファイル: _value.py プロジェクト: nejucomo/dimana
 def m(self, other):
     typecheck(other, Value)
     self.units.match(other.units)
     return method(self, other)
コード例 #7
0
ファイル: test_typecheck.py プロジェクト: nejucomo/dimana
 def test_ok(self):
     typecheck(3, int)
コード例 #8
0
ファイル: _units.py プロジェクト: nejucomo/dimana
 def match(self, other):
     typecheck(other, Units)
     if self is not other:
         raise UnitsMismatch(self, other)