@@ -217,24 +217,19 @@ has a technical reason nor does it reduce the expressiveness of rules.
217217Rules with Sub-Schedules
218218------------------------
219219
220- Imagine you need to turn on heating three times a day for one hour,
221- but only on working days from January to April. The obvious way of doing
222- this is to define four rules:
223-
224- ::
220+ Imagine you need to turn on heating three times a day for one hour, but only on working
221+ days from January to April. The obvious way of doing this is to define four rules::
225222
226223 schedule:
227224 - { v: 23, start: "06:00", end: "07:00", months: "1-4", weekdays: "1-5" }
228225 - { v: 20, start: "11:30", end: "12:30", months: "1-4", weekdays: "1-5" }
229226 - { v: 20, start: "18:00", end: "19:00", months: "1-4", weekdays: "1-5" }
230227 - { v: "OFF" }
231228
232- But what if you want to extend the schedule to heat on Saturdays as
233- well? You'd end up changing this at three different places.
229+ But what if you want to extend the schedule to heat on Saturdays as well? You'd end
230+ up changing this at three different places.
234231
235- The more elegant way involves so-called sub-schedule rules. Look at this:
236-
237- ::
232+ The more elegant way involves so-called sub-schedule rules. Look at this::
238233
239234 schedule:
240235 - months: 1-4
@@ -245,15 +240,19 @@ The more elegant way involves so-called sub-schedule rules. Look at this:
245240 - { v: 20, start: "18:00", end: "19:00" }
246241 - v: "OFF"
247242
248- The first, outer rule containing the ``rules `` parameter isn't considered
249- for evaluation itself. Instead, it's child rules - those defined under
250- `` rules: `` - are considered, but only when the constraints of the parent
251- rule (`` months `` and `` weekdays `` in this case) are fulfilled .
243+ The first, outer rule containing the ``rules `` parameter isn't considered for
244+ evaluation itself. Instead, it's child rules ( those defined under `` rules: ``) are
245+ considered, but with all constraints of the outer rule (`` months `` and `` weekdays ``
246+ in this case) applied to them .
252247
253- We can go even further and move the ``v: 20 `` one level up, so that
254- it counts for all child rules which don't have their own ``v `` defined.
248+ .. note ::
255249
256- ::
250+ The delegation of constraints works not only for one level of
251+ sub-schedules. Sub-schedules can be nested as deep as desired and constraints
252+ are cumulated correctly.
253+
254+ We can go even further and move the ``v: 20 `` one level up, so that it counts for
255+ all child rules which don't have their own ``v `` defined::
257256
258257 schedule:
259258 - v: 20
@@ -265,18 +264,18 @@ it counts for all child rules which don't have their own ``v`` defined.
265264 - { start: "18:00", end: "19:00" }
266265 - v: "OFF"
267266
268- Note how the ``v `` for a rule is chosen. To find the value to use for a
269- particular rule, the rule is first considered itself. In case it has no
270- own ``v `` defined, all sub-schedule rules that led to this rule are then
271- scanned for a ``v `` until one is found. When looking at the indentation
272- of the YAML, this lookup is done from right to left.
267+ Note how the ``v `` for a rule is chosen. To find the value to use for a particular
268+ rule, the rule is first considered itself. In case it has no own ``v `` defined, all
269+ sub-schedule rules that led to this rule are then traversed and scanned for a ``v ``
270+ until one is found. When looking at the indentation of the YAML, this lookup is done
271+ from right to left, so that the innermost value is used. The exact same approach is
272+ taken for ``start `` and ``end ``.
273273
274- I've to admit that this was a small and well arranged example, but the
275- benefit becomes clearer when you start to write longer schedules, maybe
276- with separate sections for the different seasons.
274+ I've to admit that this was a small and well arranged example, but the benefit becomes
275+ clearer when you start to write longer schedules, maybe with separate sections for
276+ the different seasons.
277277
278- With this knowledge, writing quite powerful Schedy schedules should be
279- easy and quick.
278+ With this knowledge, writing basic Schedy schedules should be straightforward.
280279
281- The next chapter deals with expressions, which finally give you the
282- power to do whatever you can do with Python, right inside your schedules.
280+ The next chapter deals with expressions, which finally give you the power to do
281+ whatever you can do with Python, right inside your schedules.
0 commit comments