Debian Codegraph @

examples/pretty_print.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """A simple example demonstrating how to pretty print data."""
3
4 import cmd2
5
6 EXAMPLE_DATA = {
7 "name": "John Doe",
8 "age": 30,
9 "address": {"street": "123 Main St", "city": "Anytown", "state": "CA"},
10 "hobbies": ["reading", "hiking", "coding", "cooking", "running", "painting", "music", "photography", "cycling"],
11 "member": True,
12 "vip": False,
13 "phone": None,
14 }
15
16
17 class Cmd2App(cmd2.Cmd):
18 def __init__(self) -> None:
19 super().__init__()
20
21 def do_pretty(self, _: cmd2.Statement) -> None:
22 """Print an object using ppretty()."""
23 self.ppretty(EXAMPLE_DATA)
24
25
26 if __name__ == "__main__":
27 app = Cmd2App()
28 app.cmdloop()