(self, j)
| 2014 | raise ValueError, "list.remove(x): x not in list" |
| 2015 | |
| 2016 | def pop(self, j): |
| 2017 | column = list(self[j]) # Return a list copy. |
| 2018 | for row in self._datasheet: |
| 2019 | row.pop(j) |
| 2020 | # At one point a DatasheetColumn object was created with Datasheet.columns[j]. |
| 2021 | # It might still be in use somewhere, so we unlink it from the datasheet: |
| 2022 | self._cache[j]._datasheet = Datasheet(rows=[[v] for v in column]) |
| 2023 | self._cache[j]._j = 0 |
| 2024 | self._cache.pop(j) |
| 2025 | for k in range(j+1, len(self)+1): |
| 2026 | if k in self._cache: |
| 2027 | # Shift the DatasheetColumn objects on the right to the left. |
| 2028 | self._cache[k-1] = self._cache.pop(k) |
| 2029 | self._cache[k-1]._j = k-1 |
| 2030 | self._datasheet.__dict__["_m"] -= 1 # Decrease column count. |
| 2031 | # Remove the header. |
| 2032 | if self._datasheet.fields is not None: |
| 2033 | self._datasheet.fields.pop(j) |
| 2034 | return column |
| 2035 | |
| 2036 | def count(self, column): |
| 2037 | return len([True for c in self if c == column]) |
no test coverage detected