Columns can be set by field name, e.g., Datasheet.date = [...].
(self, k, v)
| 1690 | raise AttributeError, "'Datasheet' object has no attribute '%s'" % k |
| 1691 | |
| 1692 | def __setattr__(self, k, v): |
| 1693 | """ Columns can be set by field name, e.g., Datasheet.date = [...]. |
| 1694 | """ |
| 1695 | #print "Datasheet.__setattr__", k |
| 1696 | if k in self.__dict__: |
| 1697 | self.__dict__[k] = v |
| 1698 | return |
| 1699 | if k == "rows": |
| 1700 | self._set_rows(v) |
| 1701 | return |
| 1702 | if k == "columns": |
| 1703 | self._set_columns(v) |
| 1704 | return |
| 1705 | if k == "headers": |
| 1706 | self._set_headers(v) |
| 1707 | return |
| 1708 | for i, f in enumerate(f[0] for f in self.__dict__["fields"] or []): |
| 1709 | if f == k: |
| 1710 | self.__dict__["_columns"].__setitem__(i, v); return |
| 1711 | raise AttributeError, "'Datasheet' object has no attribute '%s'" % k |
| 1712 | |
| 1713 | def __setitem__(self, index, value): |
| 1714 | """ Sets an item or row in the matrix. |
nothing calls this directly
no test coverage detected