[565184]: examples / family_relations / example_plans.py Maximize Restore History

Download this file

example_plans.py    47 lines (31 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def how_related_child_parent(context):
return context['plan#2'](context['p2_type'], context['p1_type'])
def how_related_parent_child(context):
return context['plan#2'](context['p2_type'], context['p1_type'])
def how_related_siblings(context):
return context['p2_type'] + ' <=> ' + context['p1_type']
def how_related_nn_au(context):
return context['plan#2'](context['p2_type'], context['p1_type'])
def how_related_au_nn(context):
return context['plan#2'](context['p2_type'], context['p1_type'])
def how_related_cousins(context):
return context['plan#2']()
def how_related_removed_cousins(context):
nth_cousin = context['plan#3']()
return "%s, %d removed" % (nth_cousin, context['r1'])
def how_related_cousins_removed(context):
nth_cousin = context['plan#3']()
return "%s, %d removed" % (nth_cousin, context['r1'])
def nth_cousin_1(context):
return "1st cousins"
def nth_cousin_2(context):
return "2nd cousins"
def nth_cousin_3(context):
return "3rd cousins"
def nth_cousin_rest(context):
return "%dth cousins" % context['n']
def add_empty_prefix(context, x, y):
return x + ' <=> ' + y
def add_prefix(context, x, y):
pre = ' '.join(context['prefix']) + ' '
return pre + x + ' <=> ' + pre + y