Skip to content

Commit

Permalink
module: add debug() alias for pprint() with non-yaml types
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-fg committed Dec 11, 2024
1 parent 09eda7f commit 7c628d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pyaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,22 @@ def dump( data, dst=None, safe=None, force_embed=True, vspacing=True,
# Simplier pyaml.dump() aliases

def dump_all(data, *dump_args, **dump_kws):
'Alias to dump(list, multiple_docs=True) for API compatibility with pyyaml'
return dump(data, *dump_args, multiple_docs=True, **dump_kws)

def dumps(data, **dump_kws):
'Alias to dump() for API compatibility with stdlib conventions'
return dump(data, **dump_kws)

def pprint(*data, **dump_kws):
'Similar to how print() works, with any number of arguments and stdout-default'
dst = dump_kws.pop('file', dump_kws.pop('dst', sys.stdout))
if len(data) == 1: data, = data
dump(data, dst=dst, **dump_kws)

def debug(*data, **dump_kws):
'Same as pprint, but also repr-printing any non-yaml types'
pprint(*data, repr_unknown=True, **dump_kws)

_p = lambda *a,_p=print,**kw: _p(*a, **kw, flush=True) # to use here for debug
p = print = pprint
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]

name = "pyaml"
version = "24.12.0"
version = "24.12.1"

description = "PyYAML-based module to produce a bit more pretty and readable YAML-serialized data"
authors = [{name="Mike Kazantsev", email="mk.fraggod@gmail.com"}]
Expand Down

0 comments on commit 7c628d0

Please sign in to comment.