%global _empty_manifest_terminate_build 0 Name: python-tomli-w Version: 1.0.0 Release: 1 Summary: A lil' TOML writer License: MIT License URL: https://github.com/hukkin/tomli-w Source0: https://mirrors.nju.edu.cn/pypi/web/packages/49/05/6bf21838623186b91aedbda06248ad18f03487dc56fbc20e4db384abde6c/tomli_w-1.0.0.tar.gz BuildArch: noarch %description [![Build Status](https://github.com/hukkin/tomli-w/workflows/Tests/badge.svg?branch=master)](https://github.com/hukkin/tomli-w/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush) [![codecov.io](https://codecov.io/gh/hukkin/tomli-w/branch/master/graph/badge.svg)](https://codecov.io/gh/hukkin/tomli-w) [![PyPI version](https://img.shields.io/pypi/v/tomli-w)](https://pypi.org/project/tomli-w) # Tomli-W > A lil' TOML writer **Table of Contents** *generated with [mdformat-toc](https://github.com/hukkin/mdformat-toc)* - [Intro](#intro) - [Installation](#installation) - [Usage](#usage) - [Write to string](#write-to-string) - [Write to file](#write-to-file) - [FAQ](#faq) - [Does Tomli-W sort the document?](#does-tomli-w-sort-the-document) - [Does Tomli-W support writing documents with comments or custom whitespace?](#does-tomli-w-support-writing-documents-with-comments-or-custom-whitespace) - [Why does Tomli-W not write a multi-line string if the string value contains newlines?](#why-does-tomli-w-not-write-a-multi-line-string-if-the-string-value-contains-newlines) - [Is Tomli-W output guaranteed to be valid TOML?](#is-tomli-w-output-guaranteed-to-be-valid-toml) ## Intro Tomli-W is a Python library for writing [TOML](https://toml.io). It is a write-only counterpart to [Tomli](https://github.com/hukkin/tomli), which is a read-only TOML parser. Tomli-W is fully compatible with [TOML v1.0.0](https://toml.io/en/v1.0.0). ## Installation ```bash pip install tomli-w ``` ## Usage ### Write to string ```python import tomli_w doc = {"table": {"nested": {}, "val3": 3}, "val2": 2, "val1": 1} expected_toml = """\ val2 = 2 val1 = 1 [table] val3 = 3 [table.nested] """ assert tomli_w.dumps(doc) == expected_toml ``` ### Write to file ```python import tomli_w doc = {"one": 1, "two": 2, "pi": 3} with open("path_to_file/conf.toml", "wb") as f: tomli_w.dump(doc, f) ``` ## FAQ ### Does Tomli-W sort the document? No, but it respects sort order of the input data, so one could sort the content of the `dict` (recursively) before calling `tomli_w.dumps`. ### Does Tomli-W support writing documents with comments or custom whitespace? No. ### Why does Tomli-W not write a multi-line string if the string value contains newlines? This default was chosen to achieve lossless parse/write round-trips. TOML strings can contain newlines where exact bytes matter, e.g. ```toml s = "here's a newline\r\n" ``` TOML strings also can contain newlines where exact byte representation is not relevant, e.g. ```toml s = """here's a newline """ ``` A parse/write round-trip that converts the former example to the latter does not preserve the original newline byte sequence. This is why Tomli-W avoids writing multi-line strings. A keyword argument is provided for users who do not need newline bytes to be preserved: ```python import tomli_w doc = {"s": "here's a newline\r\n"} expected_toml = '''\ s = """ here's a newline """ ''' assert tomli_w.dumps(doc, multiline_strings=True) == expected_toml ``` ### Is Tomli-W output guaranteed to be valid TOML? No. If there's a chance that your input data is bad and you need output validation, parse the output string once with `tomli.loads`. If the parse is successful (does not raise `tomli.TOMLDecodeError`) then the string is valid TOML. %package -n python3-tomli-w Summary: A lil' TOML writer Provides: python-tomli-w BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-tomli-w [![Build Status](https://github.com/hukkin/tomli-w/workflows/Tests/badge.svg?branch=master)](https://github.com/hukkin/tomli-w/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush) [![codecov.io](https://codecov.io/gh/hukkin/tomli-w/branch/master/graph/badge.svg)](https://codecov.io/gh/hukkin/tomli-w) [![PyPI version](https://img.shields.io/pypi/v/tomli-w)](https://pypi.org/project/tomli-w) # Tomli-W > A lil' TOML writer **Table of Contents** *generated with [mdformat-toc](https://github.com/hukkin/mdformat-toc)* - [Intro](#intro) - [Installation](#installation) - [Usage](#usage) - [Write to string](#write-to-string) - [Write to file](#write-to-file) - [FAQ](#faq) - [Does Tomli-W sort the document?](#does-tomli-w-sort-the-document) - [Does Tomli-W support writing documents with comments or custom whitespace?](#does-tomli-w-support-writing-documents-with-comments-or-custom-whitespace) - [Why does Tomli-W not write a multi-line string if the string value contains newlines?](#why-does-tomli-w-not-write-a-multi-line-string-if-the-string-value-contains-newlines) - [Is Tomli-W output guaranteed to be valid TOML?](#is-tomli-w-output-guaranteed-to-be-valid-toml) ## Intro Tomli-W is a Python library for writing [TOML](https://toml.io). It is a write-only counterpart to [Tomli](https://github.com/hukkin/tomli), which is a read-only TOML parser. Tomli-W is fully compatible with [TOML v1.0.0](https://toml.io/en/v1.0.0). ## Installation ```bash pip install tomli-w ``` ## Usage ### Write to string ```python import tomli_w doc = {"table": {"nested": {}, "val3": 3}, "val2": 2, "val1": 1} expected_toml = """\ val2 = 2 val1 = 1 [table] val3 = 3 [table.nested] """ assert tomli_w.dumps(doc) == expected_toml ``` ### Write to file ```python import tomli_w doc = {"one": 1, "two": 2, "pi": 3} with open("path_to_file/conf.toml", "wb") as f: tomli_w.dump(doc, f) ``` ## FAQ ### Does Tomli-W sort the document? No, but it respects sort order of the input data, so one could sort the content of the `dict` (recursively) before calling `tomli_w.dumps`. ### Does Tomli-W support writing documents with comments or custom whitespace? No. ### Why does Tomli-W not write a multi-line string if the string value contains newlines? This default was chosen to achieve lossless parse/write round-trips. TOML strings can contain newlines where exact bytes matter, e.g. ```toml s = "here's a newline\r\n" ``` TOML strings also can contain newlines where exact byte representation is not relevant, e.g. ```toml s = """here's a newline """ ``` A parse/write round-trip that converts the former example to the latter does not preserve the original newline byte sequence. This is why Tomli-W avoids writing multi-line strings. A keyword argument is provided for users who do not need newline bytes to be preserved: ```python import tomli_w doc = {"s": "here's a newline\r\n"} expected_toml = '''\ s = """ here's a newline """ ''' assert tomli_w.dumps(doc, multiline_strings=True) == expected_toml ``` ### Is Tomli-W output guaranteed to be valid TOML? No. If there's a chance that your input data is bad and you need output validation, parse the output string once with `tomli.loads`. If the parse is successful (does not raise `tomli.TOMLDecodeError`) then the string is valid TOML. %package help Summary: Development documents and examples for tomli-w Provides: python3-tomli-w-doc %description help [![Build Status](https://github.com/hukkin/tomli-w/workflows/Tests/badge.svg?branch=master)](https://github.com/hukkin/tomli-w/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush) [![codecov.io](https://codecov.io/gh/hukkin/tomli-w/branch/master/graph/badge.svg)](https://codecov.io/gh/hukkin/tomli-w) [![PyPI version](https://img.shields.io/pypi/v/tomli-w)](https://pypi.org/project/tomli-w) # Tomli-W > A lil' TOML writer **Table of Contents** *generated with [mdformat-toc](https://github.com/hukkin/mdformat-toc)* - [Intro](#intro) - [Installation](#installation) - [Usage](#usage) - [Write to string](#write-to-string) - [Write to file](#write-to-file) - [FAQ](#faq) - [Does Tomli-W sort the document?](#does-tomli-w-sort-the-document) - [Does Tomli-W support writing documents with comments or custom whitespace?](#does-tomli-w-support-writing-documents-with-comments-or-custom-whitespace) - [Why does Tomli-W not write a multi-line string if the string value contains newlines?](#why-does-tomli-w-not-write-a-multi-line-string-if-the-string-value-contains-newlines) - [Is Tomli-W output guaranteed to be valid TOML?](#is-tomli-w-output-guaranteed-to-be-valid-toml) ## Intro Tomli-W is a Python library for writing [TOML](https://toml.io). It is a write-only counterpart to [Tomli](https://github.com/hukkin/tomli), which is a read-only TOML parser. Tomli-W is fully compatible with [TOML v1.0.0](https://toml.io/en/v1.0.0). ## Installation ```bash pip install tomli-w ``` ## Usage ### Write to string ```python import tomli_w doc = {"table": {"nested": {}, "val3": 3}, "val2": 2, "val1": 1} expected_toml = """\ val2 = 2 val1 = 1 [table] val3 = 3 [table.nested] """ assert tomli_w.dumps(doc) == expected_toml ``` ### Write to file ```python import tomli_w doc = {"one": 1, "two": 2, "pi": 3} with open("path_to_file/conf.toml", "wb") as f: tomli_w.dump(doc, f) ``` ## FAQ ### Does Tomli-W sort the document? No, but it respects sort order of the input data, so one could sort the content of the `dict` (recursively) before calling `tomli_w.dumps`. ### Does Tomli-W support writing documents with comments or custom whitespace? No. ### Why does Tomli-W not write a multi-line string if the string value contains newlines? This default was chosen to achieve lossless parse/write round-trips. TOML strings can contain newlines where exact bytes matter, e.g. ```toml s = "here's a newline\r\n" ``` TOML strings also can contain newlines where exact byte representation is not relevant, e.g. ```toml s = """here's a newline """ ``` A parse/write round-trip that converts the former example to the latter does not preserve the original newline byte sequence. This is why Tomli-W avoids writing multi-line strings. A keyword argument is provided for users who do not need newline bytes to be preserved: ```python import tomli_w doc = {"s": "here's a newline\r\n"} expected_toml = '''\ s = """ here's a newline """ ''' assert tomli_w.dumps(doc, multiline_strings=True) == expected_toml ``` ### Is Tomli-W output guaranteed to be valid TOML? No. If there's a chance that your input data is bad and you need output validation, parse the output string once with `tomli.loads`. If the parse is successful (does not raise `tomli.TOMLDecodeError`) then the string is valid TOML. %prep %autosetup -n tomli-w-1.0.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-tomli-w -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri Apr 21 2023 Python_Bot - 1.0.0-1 - Package Spec generated