James Ennis pushed to branch master at BuildStream / buildstream
Commits:
-
f069d82f
by Daniel Silverstone at 2018-10-26T12:19:58Z
-
283887a5
by James Ennis at 2018-10-26T13:12:12Z
4 changed files:
Changes:
... | ... | @@ -335,16 +335,9 @@ def node_get_provenance(node, key=None, indices=None): |
335 | 335 |
return provenance
|
336 | 336 |
|
337 | 337 |
|
338 |
-# Helper to use utils.sentinel without unconditional utils import,
|
|
339 |
-# which causes issues for completion.
|
|
340 |
-#
|
|
341 |
-# Local private, but defined here because sphinx appears to break if
|
|
342 |
-# it's not defined before any functions calling it in default kwarg
|
|
343 |
-# values.
|
|
344 |
-#
|
|
345 |
-def _get_sentinel():
|
|
346 |
- from .utils import _sentinel
|
|
347 |
- return _sentinel
|
|
338 |
+# A sentinel to be used as a default argument for functions that need
|
|
339 |
+# to distinguish between a kwarg set to None and an unset kwarg.
|
|
340 |
+_sentinel = object()
|
|
348 | 341 |
|
349 | 342 |
|
350 | 343 |
# node_get()
|
... | ... | @@ -368,10 +361,10 @@ def _get_sentinel(): |
368 | 361 |
# Note:
|
369 | 362 |
# Returned strings are stripped of leading and trailing whitespace
|
370 | 363 |
#
|
371 |
-def node_get(node, expected_type, key, indices=None, default_value=_get_sentinel()):
|
|
364 |
+def node_get(node, expected_type, key, indices=None, default_value=_sentinel):
|
|
372 | 365 |
value = node.get(key, default_value)
|
373 | 366 |
provenance = node_get_provenance(node)
|
374 |
- if value is _get_sentinel():
|
|
367 |
+ if value is _sentinel:
|
|
375 | 368 |
raise LoadError(LoadErrorReason.INVALID_DATA,
|
376 | 369 |
"{}: Dictionary did not contain expected key '{}'".format(provenance, key))
|
377 | 370 |
|
... | ... | @@ -451,7 +451,7 @@ class Element(Plugin): |
451 | 451 |
|
452 | 452 |
return None
|
453 | 453 |
|
454 |
- def node_subst_member(self, node, member_name, default=utils._sentinel):
|
|
454 |
+ def node_subst_member(self, node, member_name, default=_yaml._sentinel):
|
|
455 | 455 |
"""Fetch the value of a string node member, substituting any variables
|
456 | 456 |
in the loaded value with the element contextual variables.
|
457 | 457 |
|
... | ... | @@ -321,7 +321,7 @@ class Plugin(): |
321 | 321 |
provenance = _yaml.node_get_provenance(node, key=member_name)
|
322 | 322 |
return str(provenance)
|
323 | 323 |
|
324 |
- def node_get_member(self, node, expected_type, member_name, default=utils._sentinel):
|
|
324 |
+ def node_get_member(self, node, expected_type, member_name, default=_yaml._sentinel):
|
|
325 | 325 |
"""Fetch the value of a node member, raising an error if the value is
|
326 | 326 |
missing or incorrectly typed.
|
327 | 327 |
|
... | ... | @@ -654,10 +654,6 @@ def _pretty_size(size, dec_places=0): |
654 | 654 |
return "{size:g}{unit}".format(size=round(psize, dec_places), unit=unit)
|
655 | 655 |
|
656 | 656 |
|
657 |
-# A sentinel to be used as a default argument for functions that need
|
|
658 |
-# to distinguish between a kwarg set to None and an unset kwarg.
|
|
659 |
-_sentinel = object()
|
|
660 |
- |
|
661 | 657 |
# Main process pid
|
662 | 658 |
_main_pid = os.getpid()
|
663 | 659 |
|