-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
from __future__ import unicode_literals | ||
from sys import stdout | ||
|
||
from eliot import start_action, start_task, to_file | ||
to_file(stdout) | ||
|
||
|
||
class Person(object): | ||
def __init__(self, name): | ||
self.name = name | ||
|
||
|
||
class Place(object): | ||
def __init__(self, name, contained=()): | ||
self.name = name | ||
self.contained = contained | ||
|
||
def visited(self, person): | ||
with start_action(action_type="place:visited", | ||
person=person.name, | ||
place=self.name): | ||
person=person, place=self.name): | ||
for thing in self.contained: | ||
thing.visited(person) | ||
|
||
|
||
def honeymoon(family): | ||
with start_task(action_type="honeymoon", | ||
family=[person.name for person in family]): | ||
rome = Place("Rome, Italy", [Place("Vatican Museum", | ||
[Place("Statue #1"), | ||
Place("Statue #2")])]) | ||
with start_task(action_type="honeymoon", family=family): | ||
rome = Place("Rome, Italy", | ||
[Place("Vatican Museum", | ||
[Place("Statue #1"), Place("Statue #2")])]) | ||
for person in family: | ||
rome.visited(person) | ||
|
||
|
||
if __name__ == '__main__': | ||
honeymoon([Person("Mrs. Casaubon"), Person("Mr. Casaubon")]) | ||
honeymoon(["Mrs. Casaubon", "Mr. Casaubon"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
from __future__ import unicode_literals | ||
from sys import stdout | ||
|
||
from eliot import Message, to_file | ||
to_file(stdout) | ||
|
||
|
||
class Person(object): | ||
def __init__(self, name): | ||
self.name = name | ||
|
||
|
||
class Place(object): | ||
def __init__(self, name, contained=()): | ||
self.name = name | ||
self.contained = contained | ||
|
||
def visited(self, person): | ||
Message.log(message_type="place:visited", | ||
person=person.name, | ||
place=self.name) | ||
person=person, place=self.name) | ||
for thing in self.contained: | ||
thing.visited(person) | ||
|
||
|
||
def honeymoon(family): | ||
Message.log(message_type="honeymoon", | ||
family=[person.name for person in family]) | ||
rome = Place("Rome, Italy", [Place("Vatican Museum", | ||
[Place("Statue #1"), | ||
Place("Statue #2")])]) | ||
Message.log(message_type="honeymoon", family=family) | ||
rome = Place("Rome, Italy", | ||
[Place("Vatican Museum", | ||
[Place("Statue #1"), Place("Statue #2")])]) | ||
for person in family: | ||
rome.visited(person) | ||
|
||
|
||
if __name__ == '__main__': | ||
honeymoon([Person("Mrs. Casaubon"), Person("Mr. Casaubon")]) | ||
honeymoon(["Mrs. Casaubon", "Mr. Casaubon"]) |