summaryrefslogtreecommitdiff
path: root/src/conf-mode/vyos-update-crontab.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2017-09-08 04:06:29 +0200
committerDaniil Baturin <daniil@baturin.org>2017-09-08 04:06:29 +0200
commit4f47f37280d774fb7ad935616c8391d0689a1f36 (patch)
treeafa2412d86da8bf8f41c5881fcee137ffcd7e825 /src/conf-mode/vyos-update-crontab.py
parent244da328e258921dd8d5e0bd773e622e252d8580 (diff)
downloadvyos-1x-4f47f37280d774fb7ad935616c8391d0689a1f36.tar.gz
vyos-1x-4f47f37280d774fb7ad935616c8391d0689a1f36.zip
Make the vyos.config.Config's return_value(s) and list_node functions behave like their Perl counterparts.
Most scripts used to do something like my $foo = $config->returnValue("system foo"); if !defined($foo) { $foo = $defaultFooValue; } In most cases values do not exist because they are optional and simply not set. In a substantial minority of cases they don't exist but are mandatory, in this case it's probably a good practice to check if it exists first. In rare but frustrating cases returnValue returns undef because the path is wrong. It was tempting but as it turns out impractical to force the user to handle every undefined value as an error, but the cost of wrapping every return_value call in a try/except block is too high. Instead we should facilitate the most common case. For this, those functions now support an optional named argument default=None so an optional value with a sensible default can be handled like $foo = config.return_value("system foo", default="bar")
Diffstat (limited to 'src/conf-mode/vyos-update-crontab.py')
0 files changed, 0 insertions, 0 deletions