예제 #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
 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)