MCPcopy Index your code
hub / github.com/clips/pattern / __setattr__

Method __setattr__

pattern/db/__init__.py:1692–1711  ·  view source on GitHub ↗

Columns can be set by field name, e.g., Datasheet.date = [...].

(self, k, v)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 4

_set_rowsMethod · 0.95
_set_columnsMethod · 0.95
_set_headersMethod · 0.80
__setitem__Method · 0.45

Tested by

no test coverage detected