pyconfs/configuration.py
def as_str(
        self,
        format: Optional[str] = None,
        *,
        indent: int = 2,
        key_width: int = 20,
        skip_header: bool = False,
        **writer_args: Any,
    ) -> str:
        """Represent Configuration as a string, heavily inspired by TOML"""
        if format is not None:
            return writers.as_str(format, config=self.as_dict(), **writer_args)

        lines = [] if self.name is None or skip_header else [f"[{self.name}]"]
        for key, value in self.data.items():
            if isinstance(value, IsConfiguration):
                value_str = value.as_str(indent=indent, key_width=key_width)
                lines.append("\n" + textwrap.indent(value_str, " " * indent))
            else:
                lines.append(f"{key:<{key_width}} = {_repr_toml(value)}")
        return "\n".join(lines)
Represent Configuration as a string, heavily inspired by TOML
Represent Configuration as a string, heavily inspired by TOML
Represent Configuration as a string heavily inspired by TOML
def as_str(
        self,
        format: Optional[str] = None,
        *,
        indent: int = 2,
        key_width: int = 20,
        skip_header: bool = False,
        **writer_args: Any,
    ) -> str:
        if format is not None:
            return writers.as_str(format, config=self.as_dict(), **writer_args)
        lines = [] if self.name is None or skip_header else [f"[{self.name}]"]
        for key, value in self.data.items():
            if isinstance(value, IsConfiguration):
                value_str = value.as_str(indent=indent, key_width=key_width)
                lines.append("\n" + textwrap.indent(value_str, " " * indent))
            else:
                lines.append(f"{key:<{key_width}} = {_repr_toml(value)}")
        return "\n".join(lines)
def as_str ( self , format : Optional [ str ] = None , * , indent : int = 2 , key_width : int = 20 , skip_header : bool = False , ** writer_args : Any , ) -> str : if format is not None : return writers . as_str ( format , config = self . as_dict ( ) , ** writer_args ) lines = [ ] if self . name is None or skip_header else [ f"[{self.name}]" ] for key , value in self . data . items ( ) : if isinstance ( value , IsConfiguration ) : value_str = value . as_str ( indent = indent , key_width = key_width ) lines . append ( "\n" + textwrap . indent ( value_str , " " * indent ) ) else : lines . append ( f"{key:<{key_width}} = {_repr_toml(value)}" ) return "\n" . join ( lines )
Represent Configuration as a string, heavily inspired by TOML
Represent Configuration as a string heavily inspired by TOML
"""Represent Configuration as a string, heavily inspired by TOML"""
self
format
Optional[str]
indent
int
key_width
int
skip_header
bool
writer_args
Any