|
11 | 11 | from pycaching.log import Log, Type as LogType |
12 | 12 | from pycaching.util import parse_date, rot13, lazy_loaded |
13 | 13 |
|
14 | | -# prefix _type() function to avoid colisions with cache type |
| 14 | +# prefix _type() function to avoid collisions with cache type |
15 | 15 | _type = type |
16 | 16 |
|
17 | 17 |
|
@@ -167,7 +167,7 @@ def __init__(self, geocaching, wp, **kwargs): |
167 | 167 | known_kwargs = {"name", "type", "location", "original_location", "state", "found", "size", |
168 | 168 | "difficulty", "terrain", "author", "hidden", "attributes", "summary", |
169 | 169 | "description", "hint", "favorites", "pm_only", "url", "waypoints", "_logbook_token", |
170 | | - "_trackable_page_url", "guid"} |
| 170 | + "_trackable_page_url", "guid", "visited"} |
171 | 171 |
|
172 | 172 | for name in known_kwargs: |
173 | 173 | if name in kwargs: |
@@ -463,6 +463,25 @@ def hidden(self, hidden): |
463 | 463 | "Passed object is not datetime.date instance nor string containing a date.") |
464 | 464 | self._hidden = hidden |
465 | 465 |
|
| 466 | + @property |
| 467 | + def visited(self): |
| 468 | + """The cache log date (filled by function geocaching.my_logs() if cache is created there) |
| 469 | +
|
| 470 | + :setter: Set a cache log date. If :class:`str` is passed, then :meth:`.util.parse_date` |
| 471 | + is used and its return value is stored as a date. |
| 472 | + :type: :class:`datetime.date` |
| 473 | + """ |
| 474 | + return self._visited |
| 475 | + |
| 476 | + @visited.setter |
| 477 | + def visited(self, visited): |
| 478 | + if isinstance(visited, str): |
| 479 | + visited = parse_date(visited) |
| 480 | + elif not isinstance(visited, datetime.date): |
| 481 | + raise errors.ValueError( |
| 482 | + "Passed object is not datetime.date instance nor string containing a date.") |
| 483 | + self._visited = visited |
| 484 | + |
466 | 485 | @property |
467 | 486 | @lazy_loaded |
468 | 487 | def attributes(self): |
|
0 commit comments