Convert row range object to dict which can be passed to
        google.bigtable.v2.RowRange add method.
765301
def get_range_kwargs(self):
        
        range_kwargs = {}
        if self.start_key is not None:
            start_key_key = "start_key_open"
            if self.start_inclusive:
                start_key_key = "start_key_closed"
            range_kwargs[start_key_key] = _to_bytes(self.start_key)

        if self.end_key is not None:
            end_key_key = "end_key_open"
            if self.end_inclusive:
                end_key_key = "end_key_closed"
            range_kwargs[end_key_key] = _to_bytes(self.end_key)
        return range_kwargs
777531
def convert_table(table):
    

    return dict((ord(k), v) for k, v in table.items())
259144
def format_row(self, row):
        
        res = []
        headers = getattr(self, 'headers', [])
        for column in headers:
            column_name = column['name']
            value = row.get(column_name, '')
            if hasattr(self, "format_%s" % column_name):
                value = getattr(self, "format_%s" % column_name)(value)
            res.append(value)
        return res
1152543
def _clean_dict(row):
    
    row_cleaned = {}
    for key, val in row.items():
        if val is None or val == '':
            row_cleaned[key] = None
        else:
            row_cleaned[key] = val
    return row_cleaned
1018391
def _map_channel_row_to_dict(self, row):
        
        channel_cleaned = _clean_dict(row)
        channel_dict = dict(
            title=channel_cleaned[CHANNEL_TITLE_KEY],
            description=channel_cleaned[CHANNEL_DESCRIPTION_KEY],
            source_domain=channel_cleaned[CHANNEL_DOMAIN_KEY],
            source_id=channel_cleaned[CHANNEL_SOURCEID_KEY],
            language=channel_cleaned[CHANNEL_LANGUAGE_KEY],
            thumbnail_chan_path=channel_cleaned[CHANNEL_THUMBNAIL_KEY]
        )
        return channel_dict
919053
def convert_row(self, keyed_row, schema, fallbacks):
        
        for key, value in list(keyed_row.items()):
            field = schema.get_field(key)
            if not field:
                del keyed_row[key]
            if key in fallbacks:
                value = _uncast_value(value, field=field)
            else:
                value = field.cast_value(value)
            keyed_row[key] = value
        return keyed_row
1309790
def append(self, row_dict):
        """"""
        # TODO validate row_dict.keys() match
        # TODO check self.is_authed
        entry = self.client.InsertRow(row_dict, self.key, self.worksheet)
        self.feed.entry.append(entry)
        return GDataRow(entry, sheet=self, deferred_save=self.deferred_save)
1003780
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'location' in _dict:
            args['location'] = Location._from_dict(_dict.get('location'))
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'section_title' in _dict:
            args['section_title'] = SectionTitle._from_dict(
                _dict.get('section_title'))
        if 'table_headers' in _dict:
            args['table_headers'] = [
                TableHeaders._from_dict(x) for x in (_dict.get('table_headers'))
            ]
        if 'row_headers' in _dict:
            args['row_headers'] = [
                RowHeaders._from_dict(x) for x in (_dict.get('row_headers'))
            ]
        if 'column_headers' in _dict:
            args['column_headers'] = [
                ColumnHeaders._from_dict(x)
                for x in (_dict.get('column_headers'))
            ]
        if 'key_value_pairs' in _dict:
            args['key_value_pairs'] = [
                KeyValuePair._from_dict(x)
                for x in (_dict.get('key_value_pairs'))
            ]
        if 'body_cells' in _dict:
            args['body_cells'] = [
                BodyCells._from_dict(x) for x in (_dict.get('body_cells'))
            ]
        return cls(**args)
1358061
def from_range(cls, data, name=None, dtype=None, **kwargs):
        
        if not isinstance(data, range):
            raise TypeError(
                '{0}(...) must be called with object coercible to a '
                'range, {1} was passed'.format(cls.__name__, repr(data)))

        start, stop, step = data.start, data.stop, data.step
        return RangeIndex(start, stop, step, dtype=dtype, name=name, **kwargs)
87897
def _transform_row(self, row):
        
        tmp_row = []

        for i, column in enumerate(row.value):
            if column.has_array_value:
                raise NotImplementedError('array types are not supported')
            elif column.scalar_value.null:
                tmp_row.append(None)
            else:
                field_name, rep, mutate_to, cast_from = self._column_data_types[i]

                # get the value from the field_name
                value = getattr(column.scalar_value, field_name)

                # cast the value
                if cast_from is not None:
                    value = cast_from(value)

                tmp_row.append(value)
        return tmp_row
1148027
def get_member(row, key):
    '''  '''
    (target, tkey, tvalue) = dict_crawl(row, key)
    if target:
        return tvalue
    return None
399044
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'cell_id') and self.cell_id is not None:
            _dict['cell_id'] = self.cell_id
        if hasattr(self, 'location') and self.location is not None:
            _dict['location'] = self.location
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self,
                   'row_index_begin') and self.row_index_begin is not None:
            _dict['row_index_begin'] = self.row_index_begin
        if hasattr(self, 'row_index_end') and self.row_index_end is not None:
            _dict['row_index_end'] = self.row_index_end
        if hasattr(
                self,
                'column_index_begin') and self.column_index_begin is not None:
            _dict['column_index_begin'] = self.column_index_begin
        if hasattr(self,
                   'column_index_end') and self.column_index_end is not None:
            _dict['column_index_end'] = self.column_index_end
        return _dict
391406
def dict_row_reader(self):
        

        rows = self.unpacked_contents

        if not rows:
            return

        header = rows.pop(0)

        for row in rows:
            yield dict(list(zip(header, row)))
963327
def cells(self):
        
        return {row_key: {column_key:cell for column_key, cell in zip(self._column_keys, cells)}
                for row_key, cells in self._rows_mapping.items()}
806635
def row_factory(cursor, row):
    """"""
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d
741932
def addRow(self, *row):
        
        row     = [ str(item) for item in row ]
        len_row = [ len(item) for item in row ]
        width   = self.__width
        len_old = len(width)
        len_new = len(row)
        known   = min(len_old, len_new)
        missing = len_new - len_old
        if missing > 0:
            width.extend( len_row[ -missing : ] )
        elif missing < 0:
            len_row.extend( [0] * (-missing) )
        self.__width = [ max( width[i], len_row[i] ) for i in compat.xrange(len(len_row)) ]
        self.__cols.append(row)
1214679
def AddRow(self, values):
    
    if self._number_of_columns and len(values) != self._number_of_columns:
      raise ValueError('Number of values is out of bounds.')

    if not self._column_sizes and self._columns:
      self._column_sizes = [len(column) for column in self._columns]

    value_strings = []
    for value_index, value_string in enumerate(values):
      if not isinstance(value_string, py2to3.UNICODE_TYPE):
        value_string = '{0!s}'.format(value_string)
      value_strings.append(value_string)

      self._column_sizes[value_index] = max(
          self._column_sizes[value_index], len(value_string))

    self._rows.append(value_strings)

    if not self._number_of_columns:
      self._number_of_columns = len(value_strings)