Merge branch '242-optional-numba-for-yaml-emitter' into 'development'
yaml.CSafeDumper can be subclassed Closes #242 See merge request damask/DAMASK!678
This commit is contained in:
commit
418e2f022b
|
@ -8,8 +8,10 @@ import numpy as np
|
||||||
import yaml
|
import yaml
|
||||||
try:
|
try:
|
||||||
from yaml import CSafeLoader as SafeLoader
|
from yaml import CSafeLoader as SafeLoader
|
||||||
|
from yaml import CSafeDumper as SafeDumper
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from yaml import SafeLoader # type: ignore
|
from yaml import SafeLoader # type: ignore
|
||||||
|
from yaml import SafeDumper # type: ignore
|
||||||
|
|
||||||
from ._typehints import FileHandle
|
from ._typehints import FileHandle
|
||||||
from . import Rotation
|
from . import Rotation
|
||||||
|
@ -17,20 +19,20 @@ from . import util
|
||||||
|
|
||||||
MyType = TypeVar('MyType', bound='Config')
|
MyType = TypeVar('MyType', bound='Config')
|
||||||
|
|
||||||
class NiceDumper(yaml.SafeDumper):
|
class NiceDumper(SafeDumper):
|
||||||
"""Make YAML readable for humans."""
|
"""Make YAML readable for humans."""
|
||||||
|
|
||||||
def write_line_break(self,
|
def write_line_break(self,
|
||||||
data: Optional[str] = None):
|
data: Optional[str] = None):
|
||||||
super().write_line_break(data)
|
super().write_line_break(data) # type: ignore
|
||||||
|
|
||||||
if len(self.indents) == 1:
|
if len(self.indents) == 1: # type: ignore
|
||||||
super().write_line_break()
|
super().write_line_break() # type: ignore
|
||||||
|
|
||||||
def increase_indent(self,
|
def increase_indent(self,
|
||||||
flow: bool = False,
|
flow: bool = False,
|
||||||
indentless: bool = False):
|
indentless: bool = False):
|
||||||
return super().increase_indent(flow, False)
|
return super().increase_indent(flow, False) # type: ignore
|
||||||
|
|
||||||
def represent_data(self,
|
def represent_data(self,
|
||||||
data: Any):
|
data: Any):
|
||||||
|
|
Loading…
Reference in New Issue