🔍 Code Extractor

class SimpleDataRow

Maturity: 46

A class representing a single row in a data table, inheriting from ClientValue. It stores cell data as a dictionary and provides methods for property management.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/simple_data_row.py
Lines:
5 - 16
Complexity:
simple

Purpose

SimpleDataRow is designed to represent a row within a data table structure, typically used in Office 365 API interactions. It encapsulates cell data in a dictionary format and provides mechanisms to set properties with OData type parsing. This class serves as a data transfer object for table row operations, allowing structured access to cell values and integration with Office 365 services through the ClientValue base class.

Source Code

class SimpleDataRow(ClientValue):
    """Represents a row in a data table"""

    def __init__(self, cells=None):
        """
        :param dict cells: The cells in the data table row.
        """
        self.Cells = cells

    def set_property(self, k, v, persist_changes=True):
        self.Cells = ODataType.parse_key_value_collection(v)
        return self

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

cells: A dictionary containing the cells in the data table row. Keys represent column identifiers and values represent the cell contents. Can be None during initialization, which creates an empty row. Expected format is a key-value collection compatible with ODataType parsing.

Return Value

The __init__ method returns a new SimpleDataRow instance. The set_property method returns self, enabling method chaining. When instantiated, the object provides access to row data through the Cells attribute.

Class Interface

Methods

__init__(self, cells=None)

Purpose: Initializes a new SimpleDataRow instance with optional cell data

Parameters:

  • cells: Optional dictionary containing the cells in the data table row. Defaults to None if not provided.

Returns: A new SimpleDataRow instance

set_property(self, k, v, persist_changes=True)

Purpose: Sets a property on the data row, specifically parsing the value as an OData key-value collection and assigning it to Cells

Parameters:

  • k: The property key (though in current implementation, this parameter is not used and Cells is always updated)
  • v: The value to be parsed and set. Expected to be in a format compatible with ODataType.parse_key_value_collection
  • persist_changes: Boolean flag indicating whether changes should be persisted. Defaults to True.

Returns: Returns self to enable method chaining

Attributes

Name Type Description Scope
Cells dict or None Stores the cells in the data table row as a dictionary where keys are column identifiers and values are cell contents. Can be None if no cells have been set. instance

Dependencies

  • office365.runtime.client_value
  • office365.runtime.odata.type

Required Imports

from office365.runtime.client_value import ClientValue
from office365.runtime.odata.type import ODataType

Usage Example

# Create an empty data row
row = SimpleDataRow()

# Create a data row with initial cells
cells_data = {'Column1': 'Value1', 'Column2': 'Value2', 'Column3': 123}
row = SimpleDataRow(cells=cells_data)

# Access cell data
print(row.Cells)

# Set property with OData parsing (method chaining supported)
row.set_property('Cells', {'NewColumn': 'NewValue'}, persist_changes=True)

# Chain multiple operations
row.set_property('Cells', {'A': '1'}).set_property('Cells', {'B': '2'})

Best Practices

  • Initialize with a dictionary for cells parameter to ensure proper data structure
  • Use set_property method when updating cells to ensure proper OData type parsing
  • The set_property method returns self, allowing for method chaining when multiple updates are needed
  • The persist_changes parameter in set_property should be set to True when changes need to be persisted to the backend
  • Cells attribute is public and can be accessed directly, but modifications should preferably go through set_property for consistency
  • This class is typically used as part of a larger Office 365 data table structure, not in isolation
  • Ensure cells dictionary keys match the expected column structure of the target data table

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SimpleDataTable 71.9% similar

    A class representing a data table structure that contains a collection of SimpleDataRow objects, used in SharePoint search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/simple_data_table.py
  • class ClientValue 59.5% similar

    Represents a complex type in OData/Office365 API contexts, providing property management and JSON serialization for entities without keys that exist as properties of containing entities or temporary values.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/runtime/client_value.py
  • class ResourceData 53.4% similar

    A data class representing resource data attached to change notifications sent to subscribers in Office 365 integrations. It extends ClientValue to support open-type properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/subscriptions/resource_data.py
  • class PageDetails 52.5% similar

    PageDetails is a minimal data class that inherits from ClientValue, serving as a container for page-related details in the Office365 API context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/publishing/diagnostics/page_details.py
  • class Visualization 52.0% similar

    An empty class that inherits from ClientValue, likely serving as a placeholder or base class for visualization-related functionality in the Office365 API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/views/visualization.py
← Back to Browse