Exemple #1
0
 def parse(self, string):
     try:
         # Try to format back hh:ss to seconds.
         return util.raw_seconds_short(string)
     except ValueError:
         # Fall back to a plain float.
         try:
             return float(string)
         except ValueError:
             return self.null
Exemple #2
0
 def parse(self, string):
     try:
         # Try to format back hh:ss to seconds.
         return util.raw_seconds_short(string)
     except ValueError:
         # Fall back to a plain float.
         try:
             return float(string)
         except ValueError:
             return self.null
Exemple #3
0
    def _convert(self, s):
        """Convert a M:SS or numeric string to a float.

        Return None if `s` is empty.
        Raise an InvalidQueryError if the string cannot be converted.
        """
        if not s:
            return None
        try:
            return util.raw_seconds_short(s)
        except ValueError:
            try:
                return float(s)
            except ValueError:
                raise InvalidQueryArgumentTypeError(s, u"a M:SS string or a float")
Exemple #4
0
    def _convert(self, s):
        """Convert a M:SS or numeric string to a float.

        Return None if `s` is empty.
        Raise an InvalidQueryError if the string cannot be converted.
        """
        if not s:
            return None
        try:
            return util.raw_seconds_short(s)
        except ValueError:
            try:
                return float(s)
            except ValueError:
                raise InvalidQueryArgumentTypeError(
                    s, u"a M:SS string or a float")