Ejemplo n.º 1
0
def test_get_first_line(filepath, first_line):
    """Unit test for get_first_line"""

    dialect, __header = __csv.sniff(filepath)
    __first_line = __csv.get_first_line(filepath, dialect)

    assert __first_line == first_line
Ejemplo n.º 2
0
    def __init__(self, *args, **kwds):
        self.csvfilepath = kwds.pop("csvfilepath")
        self.csvfilename = os.path.split(self.csvfilepath)[1]

        kwds["style"] = \
            wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.THICK_FRAME

        wx.Dialog.__init__(self, *args, **kwds)

        self.csvwidgets = CsvParameterWidgets(self, self.csvfilepath)

        dialect, self.has_header = sniff(self.csvfilepath)

        self.grid = CSVPreviewGrid(self,
                                   -1,
                                   has_header=self.has_header,
                                   csvfilepath=self.csvfilepath)

        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
        self.button_ok = wx.Button(self, wx.ID_OK, "")

        self._set_properties()
        self._do_layout()

        self.grid.fill_cells(dialect, self.has_header)
Ejemplo n.º 3
0
def test_get_first_line(filepath, first_line):
    """Unit test for get_first_line"""

    dialect, __header = __csv.sniff(filepath)
    __first_line = __csv.get_first_line(filepath, dialect)

    assert __first_line == first_line
Ejemplo n.º 4
0
def test_sniff(filepath, header, delimiter, doublequote, quoting, quotechar, lineterminator, skipinitialspace):
    """Unit test for sniff"""

    dialect, __header = __csv.sniff(filepath)
    assert __header == header
    assert dialect.delimiter == delimiter
    assert dialect.doublequote == doublequote
    assert dialect.quoting == quoting
    assert dialect.quotechar == quotechar
    assert dialect.lineterminator == lineterminator
    assert dialect.skipinitialspace == skipinitialspace
Ejemplo n.º 5
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        filepath = TESTPATH + "test1.csv"
        self.dialect, __ = sniff(filepath)
        self.digest_types = [types.UnicodeType]
        has_header = True

        self.interface = CsvInterface(self.main_window, filepath, self.dialect, self.digest_types, has_header)
Ejemplo n.º 6
0
def test_sniff(filepath, header, delimiter, doublequote, quoting, quotechar,
               lineterminator, skipinitialspace):
    """Unit test for sniff"""

    dialect, __header = __csv.sniff(filepath)
    assert __header == header
    assert dialect.delimiter == delimiter
    assert dialect.doublequote == doublequote
    assert dialect.quoting == quoting
    assert dialect.quotechar == quotechar
    assert dialect.lineterminator == lineterminator
    assert dialect.skipinitialspace == skipinitialspace
Ejemplo n.º 7
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        filepath = TESTPATH + 'test1.csv'
        self.dialect, __ = sniff(filepath)
        self.digest_types = [types.UnicodeType]
        has_header = True

        self.interface = CsvInterface(self.main_window, filepath, self.dialect,
                                      self.digest_types, has_header)
Ejemplo n.º 8
0
    def __init__(self, parent, csvfilepath):
        self.parent = parent
        self.csvfilepath = csvfilepath

        if csvfilepath is None:
            dialect = csv.get_dialect(csv.list_dialects()[0])
            self.has_header = False
        else:
            dialect, self.has_header = sniff(self.csvfilepath)

        self.param_labels = []
        self.param_widgets = []

        self._setup_param_widgets()
        self._do_layout()
        self._update_settings(dialect)

        self.choice_dialects.SetSelection(0)
Ejemplo n.º 9
0
    def OnDialectChoice(self, event):
        """Updates all param widgets confirming to the selcted dialect"""

        dialect_name = event.GetString()
        value = list(self.choices['dialects']).index(dialect_name)

        if dialect_name == 'sniffer':
            dialect, self.has_header = sniff(self.csvfilepath)
        elif dialect_name == 'user':
            event.Skip()
            return None
        else:
            dialect = csv.get_dialect(dialect_name)

        #print dialect, self.has_header
        self._update_settings(dialect)

        self.choice_dialects.SetValue(value)
Ejemplo n.º 10
0
    def OnDialectChoice(self, event):
        """Updates all param widgets confirming to the selcted dialect"""

        dialect_name = event.GetString()
        value = list(self.choices['dialects']).index(dialect_name)

        if dialect_name == 'sniffer':
            if self.csvfilepath is None:
                event.Skip()
                return None
            dialect, self.has_header = sniff(self.csvfilepath)
        elif dialect_name == 'user':
            event.Skip()
            return None
        else:
            dialect = csv.get_dialect(dialect_name)

        self._update_settings(dialect)

        self.choice_dialects.SetValue(value)
Ejemplo n.º 11
0
    def __init__(self, parent, csvfilepath):
        self.parent = parent
        self.csvfilepath = csvfilepath

        self.encoding = self.standard_encodings[0]

        if csvfilepath is None:
            dialect = csv.get_dialect(csv.list_dialects()[0])
            self.has_header = False
        else:
            dialect, self.has_header = sniff(self.csvfilepath)

        self.param_labels = []
        self.param_widgets = []

        self._setup_param_widgets()
        self._do_layout()
        self._update_settings(dialect)

        self.choice_dialects.SetSelection(0)
Ejemplo n.º 12
0
    def __init__(self, *args, **kwds):
        self.csvfilepath = kwds.pop("csvfilepath")
        self.csvfilename = os.path.split(self.csvfilepath)[1]

        kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.THICK_FRAME

        wx.Dialog.__init__(self, *args, **kwds)

        self.csvwidgets = CsvParameterWidgets(self, self.csvfilepath)

        dialect, self.has_header = sniff(self.csvfilepath)

        self.grid = CSVPreviewGrid(self, -1, has_header=self.has_header, csvfilepath=self.csvfilepath)

        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
        self.button_ok = wx.Button(self, wx.ID_OK, "")

        self._set_properties()
        self._do_layout()

        self.grid.fill_cells(dialect, self.has_header)