How to use the pygsheets.Cell function in pygsheets

To help you get started, we’ve selected a few pygsheets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / pygsheetsorm / tests / test_pygsheetsorm.py View on Github external
def get_mock_cell(
    value, value_unformatted=None, column_number=1, row_number=1, format_type=None
):
    cell = mock.create_autospec(pygsheets.Cell)
    type(cell).col = PropertyMock(return_value=column_number)
    if format_type is None:
        format_type = (FormatType.CUSTOM, "")
    type(cell).format = PropertyMock(return_value=format_type)
    type(cell).row = PropertyMock(return_value=row_number)
    type(cell).value = PropertyMock(return_value=value)
    if value_unformatted is None:
        value_unformatted = value
    type(cell).value_unformatted = PropertyMock(return_value=value_unformatted)
    return cell
github salesforce / pygsheetsorm / tests / test_pygsheetsorm.py View on Github external
def repo():
    mock_worksheet = mock.create_autospec(pygsheets.Worksheet)
    cell1 = mock.create_autospec(pygsheets.Cell)
    type(cell1).col = PropertyMock(return_value=1)
    cell1.value = "This is Column 1"
    cell2 = mock.create_autospec(pygsheets.Cell)
    cell2.value = "Column2 is this One"
    type(cell2).col = PropertyMock(return_value=2)
    cells = [cell1, cell2]
    mock_worksheet.get_row.return_value = cells
    return Repository(pygsheets_worksheet=mock_worksheet)
github salesforce / pygsheetsorm / pygsheetsorm / pygsheetsorm.py View on Github external
Model: Model object populated from row
        """
        model = Model(repository=self, cell_converter=self._cell_converter)

        # Empty cells don't get returned so we create empties to work with
        columns_to_add = set(list(self._col_to_property_name.keys()))
        for cell in row:
            row_number = cell.row  # When we fill in emptyies, we need this
            try:
                columns_to_add.remove(cell.col)
            except KeyError:
                # Ignore cells that don't correspond to column headers
                pass
        for column_number in columns_to_add:
            cell_pos = (row_number, column_number)
            empty_cell = pygsheets.Cell(cell_pos, worksheet=self.worksheet)
            row.append(empty_cell)

        for cell in row:
            try:
                property_name = self._col_to_property_name[cell.col]
                model.Metadata.add_cell(cell=cell, property_name=property_name)
            except KeyError:
                # Don't set properties for any values
                # we don't have a mapping for
                # there was no header
                pass
        return model