commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/efb99f78bcf4/ Changeset: efb99f78bcf4 User: nsoranzo Date: 2013-11-08 17:46:37 Summary: Fix min/max integer param validation when either is 0. Bug introduced in commit 5b4c4cf9bc9619d51d7f2471d64896dcdd93707c . InRangeValidator would not be appended because self.min and self.max are no more strings, but integers. Reported by: Andrea Pinna <andrea.pinna@crs4.it> Affected #: 1 file diff -r fd7ab1c8f6a5d498f76b1b1a520fbceb07706769 -r efb99f78bcf48fbbc9d9e89d13efb37f618525e6 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -268,7 +268,7 @@ self.max = int( self.max ) except: raise ValueError( "An integer is required" ) - if self.min and self.max: + if self.min is not None and self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): @@ -338,15 +338,15 @@ raise ValueError( "The settings for this field require a 'value' setting and optionally a default value which must be a real number" ) if self.min: try: - float( self.min ) + self.min = float( self.min ) except: raise ValueError( "A real number is required" ) if self.max: try: - float( self.max ) + self.max = float( self.max ) except: raise ValueError( "A real number is required" ) - if self.min and self.max: + if self.min is not None and self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): https://bitbucket.org/galaxy/galaxy-central/commits/58359331901e/ Changeset: 58359331901e User: nsoranzo Date: 2013-11-08 17:59:04 Summary: Use min/max <param> attributes to validate integers/floats also when only one limit is specified. <validator type="in_range" /> already works with only one limit specified. Also check that min <= max . Affected #: 2 files diff -r efb99f78bcf48fbbc9d9e89d13efb37f618525e6 -r 58359331901ef9ebfa562c6c1ef0297e0c4c8cb5 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -268,7 +268,7 @@ self.max = int( self.max ) except: raise ValueError( "An integer is required" ) - if self.min is not None and self.max is not None: + if self.min is not None or self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): @@ -346,7 +346,7 @@ self.max = float( self.max ) except: raise ValueError( "A real number is required" ) - if self.min is not None and self.max is not None: + if self.min is not None or self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): diff -r efb99f78bcf48fbbc9d9e89d13efb37f618525e6 -r 58359331901ef9ebfa562c6c1ef0297e0c4c8cb5 lib/galaxy/tools/parameters/validation.py --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -105,10 +105,11 @@ """ @classmethod def from_element( cls, param, elem ): - return cls( elem.get( 'message', None ), elem.get( 'min', '-inf' ), elem.get( 'max', '+inf' ) ) + return cls( elem.get( 'message', None ), elem.get( 'min' ), elem.get( 'max' ) ) def __init__( self, message, range_min, range_max ): - self.min = float( range_min ) - self.max = float( range_max ) + self.min = float( range_min if range_min is not None else '-inf' ) + self.max = float( range_max if range_max is not None else 'inf' ) + assert self.min <= self.max, 'min must be less than or equal to max' # Remove unneeded 0s and decimal from floats to make message pretty. self_min_str = str( self.min ).rstrip( '0' ).rstrip( '.' ) self_max_str = str( self.max ).rstrip( '0' ).rstrip( '.' ) https://bitbucket.org/galaxy/galaxy-central/commits/493310055f1a/ Changeset: 493310055f1a User: jmchilton Date: 2013-11-09 22:56:34 Summary: Merged in nsoranzo/galaxy-central (pull request #254) Fixes for min/max <param> attributes Affected #: 2 files diff -r c92ebce92ef72ff999d1e8fd97601fb2153a09bc -r 493310055f1ac4a4b8f8f1401d855c9e6fb516ba lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -268,7 +268,7 @@ self.max = int( self.max ) except: raise ValueError( "An integer is required" ) - if self.min and self.max: + if self.min is not None or self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): @@ -338,15 +338,15 @@ raise ValueError( "The settings for this field require a 'value' setting and optionally a default value which must be a real number" ) if self.min: try: - float( self.min ) + self.min = float( self.min ) except: raise ValueError( "A real number is required" ) if self.max: try: - float( self.max ) + self.max = float( self.max ) except: raise ValueError( "A real number is required" ) - if self.min and self.max: + if self.min is not None or self.max is not None: self.validators.append( validation.InRangeValidator( None, self.min, self.max ) ) def get_html_field( self, trans=None, value=None, other_values={} ): diff -r c92ebce92ef72ff999d1e8fd97601fb2153a09bc -r 493310055f1ac4a4b8f8f1401d855c9e6fb516ba lib/galaxy/tools/parameters/validation.py --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -105,10 +105,11 @@ """ @classmethod def from_element( cls, param, elem ): - return cls( elem.get( 'message', None ), elem.get( 'min', '-inf' ), elem.get( 'max', '+inf' ) ) + return cls( elem.get( 'message', None ), elem.get( 'min' ), elem.get( 'max' ) ) def __init__( self, message, range_min, range_max ): - self.min = float( range_min ) - self.max = float( range_max ) + self.min = float( range_min if range_min is not None else '-inf' ) + self.max = float( range_max if range_max is not None else 'inf' ) + assert self.min <= self.max, 'min must be less than or equal to max' # Remove unneeded 0s and decimal from floats to make message pretty. self_min_str = str( self.min ).rstrip( '0' ).rstrip( '.' ) self_max_str = str( self.max ).rstrip( '0' ).rstrip( '.' ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org