File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ modified.
5656``` python
5757doc = yamltrip.loads(" items:\n - a\n - b" )
5858
59+ doc.root # {"items": ["a", "b"]}
5960doc[" items" ] # ["a", "b"]
6061doc[" items" , 0 ] # "a"
6162(" items" , 0 ) in doc # True
Original file line number Diff line number Diff line change @@ -93,6 +93,11 @@ def source(self) -> str:
9393 """The current YAML source text."""
9494 return self ._source
9595
96+ @property
97+ def root (self ) -> Any :
98+ """The entire document parsed as a Python object."""
99+ return self [()]
100+
96101 def __eq__ (self , other : object ) -> bool :
97102 """Compare documents by their source text."""
98103 if not isinstance (other , Document ):
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ def document(self) -> Document:
8383 raise RuntimeError (msg )
8484 return self ._document
8585
86+ @property
87+ def root (self ) -> Any :
88+ """The entire document parsed as a Python object."""
89+ return self .document .root
90+
8691 def __getitem__ (self , keys : object ) -> Any :
8792 """Retrieve the parsed value at the given path."""
8893 return self .document [keys ]
You can’t perform that action at this time.
0 commit comments