Skip to content

Commit

Permalink
Merge branch 'development' into feature/more-set-caps-to-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
wwkimball committed Apr 10, 2021
2 parents 85c29ee + 6ec2b11 commit bf0ee9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 11 additions & 1 deletion tests/test_wrappers_consoleprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from types import SimpleNamespace

from ruamel.yaml.comments import CommentedMap, CommentedSeq, TaggedScalar
from ruamel.yaml.scalarstring import PlainScalarString
from ruamel.yaml.scalarstring import PlainScalarString, FoldedScalarString

from yamlpath.wrappers import NodeCoords
from yamlpath.wrappers import ConsolePrinter
Expand Down Expand Up @@ -57,6 +57,10 @@ def test_debug_noisy(self, capsys):
logger = ConsolePrinter(args)
anchoredkey = PlainScalarString("TestKey", anchor="KeyAnchor")
anchoredval = PlainScalarString("TestVal", anchor="Anchor")
foldedstr = "123456789 123456789 123456789"
foldedstrfolds = [10, 20]
foldedval = FoldedScalarString(foldedstr)
foldedval.fold_pos = foldedstrfolds

logger.debug(anchoredval)
console = capsys.readouterr()
Expand Down Expand Up @@ -170,6 +174,12 @@ def test_debug_noisy(self, capsys):
"DEBUG: test_debug_noisy: (parentref)key",
]) + "\n" == console.out

logger.debug(foldedval)
console = capsys.readouterr()
assert "\n".join([
"DEBUG: {}<class 'ruamel.yaml.scalarstring.FoldedScalarString'>,folded@{}".format(foldedstr, foldedstrfolds)
])

def test_debug_quiet(self, capsys):
args = SimpleNamespace(verbose=False, quiet=True, debug=True)
logger = ConsolePrinter(args)
Expand Down
2 changes: 1 addition & 1 deletion yamlpath/common/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def make_new_node(
new_node = new_type(new_value)

if preserve_folds:
new_node.fold_pos = preserve_folds
new_node.fold_pos = preserve_folds # type: ignore

elif valform == YAMLValueFormats.LITERAL:
new_type = LiteralScalarString
Expand Down
3 changes: 1 addition & 2 deletions yamlpath/wrappers/consoleprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
CommentedSet,
TaggedScalar
)
from ruamel.yaml.scalarstring import FoldedScalarString

from yamlpath.wrappers.nodecoords import NodeCoords

Expand Down Expand Up @@ -274,7 +273,7 @@ def _debug_scalar(data: Any, **kwargs) -> str:
dtype = "{}({})".format(dtype, type(data.value))

# Report fold points, if present
if isinstance(data, FoldedScalarString) and hasattr(data, 'fold_pos'):
if hasattr(data, "fold_pos"):
dtype += ",folded@{}".format(data.fold_pos)

print_prefix += anchor_prefix
Expand Down

0 comments on commit bf0ee9b

Please sign in to comment.