Add i18n support & Fix error type
This commit is contained in:
parent
2f718da06f
commit
292ea99069
2 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
from classes.science.side import Side
|
||||
from gettext import gettext as _
|
||||
|
||||
class Border:
|
||||
"""
|
||||
|
@ -7,7 +8,7 @@ class Border:
|
|||
|
||||
def __init__( self , x = Side() , y = Side() ):
|
||||
if not isinstance( x , Side ) or not isinstance( y , Side ):
|
||||
raise ValueError( 'x and y should be sides' )
|
||||
raise TypeError( _( 'x and y should be sides' ) )
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from gettext import gettext as _
|
||||
|
||||
class Side:
|
||||
"""
|
||||
Set of two index from the same axis
|
||||
|
@ -5,7 +7,7 @@ class Side:
|
|||
|
||||
def __init__( self , min = 0 , max = 0 ):
|
||||
if not isinstance( min , int ) or not isinstance( max , int ):
|
||||
raise ValueError( 'min and max should be int' )
|
||||
raise TypeeError( _( 'min and max should be int' ) )
|
||||
|
||||
def scale( self , factor ):
|
||||
"""
|
||||
|
@ -13,6 +15,11 @@ class Side:
|
|||
"""
|
||||
self.min = int( self.min * factor )
|
||||
self.max = int( self.max * factor )
|
||||
def size( self ):
|
||||
"""
|
||||
Compute size of the side
|
||||
"""
|
||||
return self.max - self.min
|
||||
def __str__( self ):
|
||||
return '\
|
||||
side: [\
|
||||
|
|
Loading…
Reference in a new issue