File: dumper.py

package info (click to toggle)
python-baron 0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,080 kB
  • sloc: python: 26,926; makefile: 126; sh: 27
file content (18 lines) | stat: -rw-r--r-- 386 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from .render import RenderWalker


def dumps(tree, strict=False):
    return Dumper(strict=strict).dump(tree)


class Dumper(RenderWalker):
    def before_string(self, string, key):
        self.dump += string

    def before_constant(self, constant, key):
        self.dump += constant

    def dump(self, tree):
        self.dump = ''
        self.walk(tree)
        return self.dump