def __convert_cell(self, csv_cell_text): ret = None if self.__auto_detect_int: ret = service.detect_int_value(csv_cell_text) if ret is None and self.__auto_detect_float: ret = service.detect_float_value(csv_cell_text) shall_we_ignore_the_conversion = ( (ret in [float('inf'), float('-inf')]) and self.__ignore_infinity) if shall_we_ignore_the_conversion: ret = None if ret is None and self.__auto_detect_datetime: ret = service.detect_date_value(csv_cell_text) if ret is None: ret = csv_cell_text return ret
def __convert_cell(self, cell): if cell is None: return None if isinstance(cell, (datetime, date, time)): return cell ret = None if isinstance(cell, str): if self.__auto_detect_int: ret = service.detect_int_value(cell) if ret is None and self.__auto_detect_float: ret = service.detect_float_value(cell) shall_we_ignore_the_conversion = (ret in [ float("inf"), float("-inf") ]) and self.__ignore_infinity if shall_we_ignore_the_conversion: ret = None if ret is None: ret = cell return ret
def __convert_cell(self, csv_cell_text): ret = None if self.__auto_detect_int: ret = service.detect_int_value(csv_cell_text, self.__pep_0515_off) if ret is None and self.__auto_detect_float: ret = service.detect_float_value( csv_cell_text, self.__pep_0515_off, ignore_nan_text=self.__ignore_nan_text, default_float_nan=self.__default_float_nan, ) shall_we_ignore_the_conversion = ( ret in [float("inf"), float("-inf")] ) and self.__ignore_infinity if shall_we_ignore_the_conversion: ret = None if ret is None and self.__auto_detect_datetime: ret = service.detect_date_value(csv_cell_text) if ret is None: ret = csv_cell_text return ret
def test_suppression_of_pep_0515_int(): result = detect_int_value("123_123") eq_(result, None)
def test_detect_int_value(): result = detect_int_value("123") eq_(result, 123)
def test_detect_int_value(): result = detect_int_value('123') eq_(result, 123)