pane.io
pane.io
FileOrPath = t.Union[str, Path, TextIOBase, t.TextIO]
module-attribute
from_json(f, ty, *, custom=None)
Load an object of type ty
from a JSON file f
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
FileOrPath
|
File-like or path-like to load from |
required |
custom
|
Optional[IntoConverterHandlers]
|
Custom converters to use |
None
|
Source code in pane/io.py
from_yaml(f, ty, *, custom=None)
Load an object of type ty
from a YAML file f
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
FileOrPath
|
File-like or path-like to load from |
required |
custom
|
Optional[IntoConverterHandlers]
|
Custom converters to use |
None
|
Source code in pane/io.py
from_yaml_all(f, ty, *, custom=None)
Load an object of type ty
from a YAML file f
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
FileOrPath
|
File-like or path-like to load from |
required |
custom
|
Optional[IntoConverterHandlers]
|
Custom converters to use |
None
|
Source code in pane/io.py
write_json(obj, f, *, ty=None, indent=None, sort_keys=False, custom=None)
Write data to a JSON file f
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Convertible
|
Object to write |
required |
ty
|
Optional[IntoConverter]
|
Type of object |
None
|
f
|
FileOrPath
|
File-like or path-like to write to |
required |
indent
|
Union[str, int, None]
|
Indent to format JSON with. Defaults to None (no indentation) |
None
|
sort_keys
|
bool
|
Whether to sort keys prior to serialization. |
False
|
custom
|
Optional[IntoConverterHandlers]
|
Custom converters to use |
None
|
Source code in pane/io.py
write_yaml(obj, f, *, ty=None, indent=None, width=None, allow_unicode=True, explicit_start=True, explicit_end=False, default_style=None, default_flow_style=None, sort_keys=False, custom=None)
Write data to a YAML file f
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Convertible
|
Object to write |
required |
ty
|
Optional[IntoConverter]
|
Type of object |
None
|
f
|
FileOrPath
|
File-like or path-like to write to |
required |
indent
|
Optional[int]
|
Number of spaces to indent blocks with |
None
|
width
|
Optional[int]
|
Maximum width of file created |
None
|
allow_unicode
|
bool
|
Whether to output unicode characters or escape them |
True
|
explicit_start
|
bool
|
Whether to include a YAML document start "---" |
True
|
explicit_end
|
bool
|
Whether to include a YAML document end "..." |
False
|
default_style
|
Optional[Literal['"', '|', '>']]
|
Default style to use for scalar nodes. See YAML documentation for more information. |
None
|
default_flow_style
|
Optional[bool]
|
Whether to default to flow style or block style for collections. See YAML documentation for more information. |
None
|
sort_keys
|
bool
|
Whether to sort keys prior to serialization. |
False
|
custom
|
Optional[IntoConverterHandlers]
|
Custom converters to use |
None
|
Source code in pane/io.py
open_file(f, mode='r', newline=None, encoding='utf-8')
Open the given file for text I/O.
If given a path-like, opens it with the specified settings. Otherwise, make an effort to reconfigure the encoding, and check that it is readable/writable as specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
FileOrPath
|
File to open/reconfigure |
required |
mode
|
Literal['r', 'w']
|
Mode file should be opened in |
'r'
|
newline
|
Optional[str]
|
Newline mode file should be opened in |
None
|
encoding
|
Optional[str]
|
Encoding file should be opened in |
'utf-8'
|