semiwrap 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- semiwrap-0.1.1/.gitignore +10 -0
- semiwrap-0.1.1/LICENSE-pybind11.txt +29 -0
- semiwrap-0.1.1/LICENSE.txt +26 -0
- semiwrap-0.1.1/PKG-INFO +56 -0
- semiwrap-0.1.1/README.md +29 -0
- semiwrap-0.1.1/pyproject.toml +68 -0
- semiwrap-0.1.1/semiwrap/__init__.py +0 -0
- semiwrap-0.1.1/semiwrap/__main__.py +4 -0
- semiwrap-0.1.1/semiwrap/autowrap/__init__.py +0 -0
- semiwrap-0.1.1/semiwrap/autowrap/buffer.py +45 -0
- semiwrap-0.1.1/semiwrap/autowrap/context.py +570 -0
- semiwrap-0.1.1/semiwrap/autowrap/cxxparser.py +2067 -0
- semiwrap-0.1.1/semiwrap/autowrap/generator_data.py +386 -0
- semiwrap-0.1.1/semiwrap/autowrap/mangle.py +177 -0
- semiwrap-0.1.1/semiwrap/autowrap/render_cls_prologue.py +41 -0
- semiwrap-0.1.1/semiwrap/autowrap/render_cls_trampoline_hpp.py +442 -0
- semiwrap-0.1.1/semiwrap/autowrap/render_pybind11.py +450 -0
- semiwrap-0.1.1/semiwrap/autowrap/render_tmpl_inst.py +67 -0
- semiwrap-0.1.1/semiwrap/autowrap/render_wrapped.py +196 -0
- semiwrap-0.1.1/semiwrap/casters.py +55 -0
- semiwrap-0.1.1/semiwrap/cmd/__init__.py +0 -0
- semiwrap-0.1.1/semiwrap/cmd/dat2cpp.py +35 -0
- semiwrap-0.1.1/semiwrap/cmd/dat2tmplcpp.py +41 -0
- semiwrap-0.1.1/semiwrap/cmd/dat2tmplhpp.py +33 -0
- semiwrap-0.1.1/semiwrap/cmd/dat2trampoline.py +65 -0
- semiwrap-0.1.1/semiwrap/cmd/gen_libinit.py +53 -0
- semiwrap-0.1.1/semiwrap/cmd/gen_modinit_hpp.py +114 -0
- semiwrap-0.1.1/semiwrap/cmd/gen_pkgconf.py +46 -0
- semiwrap-0.1.1/semiwrap/cmd/header2dat.py +155 -0
- semiwrap-0.1.1/semiwrap/cmd/make_pyi.py +119 -0
- semiwrap-0.1.1/semiwrap/cmd/publish_casters.py +95 -0
- semiwrap-0.1.1/semiwrap/cmd/resolve_casters.py +71 -0
- semiwrap-0.1.1/semiwrap/config/__init__.py +0 -0
- semiwrap-0.1.1/semiwrap/config/autowrap_yml.py +659 -0
- semiwrap-0.1.1/semiwrap/config/pyproject_toml.py +219 -0
- semiwrap-0.1.1/semiwrap/config/util.py +57 -0
- semiwrap-0.1.1/semiwrap/depfile.py +32 -0
- semiwrap-0.1.1/semiwrap/hooks.py +108 -0
- semiwrap-0.1.1/semiwrap/include/gilsafe_object.h +141 -0
- semiwrap-0.1.1/semiwrap/include/pybind11_typing.h +5 -0
- semiwrap-0.1.1/semiwrap/include/semiwrap.h +86 -0
- semiwrap-0.1.1/semiwrap/makeplan.py +676 -0
- semiwrap-0.1.1/semiwrap/mkpc.py +51 -0
- semiwrap-0.1.1/semiwrap/pkgconf_cache.py +120 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/attr.h +708 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/buffer_info.h +208 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/cast.h +2194 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/chrono.h +225 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/common.h +2 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/complex.h +74 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/conduit/README.txt +15 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/conduit/pybind11_conduit_v1.h +111 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/class.h +826 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/common.h +1267 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/cpp_conduit.h +77 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/descr.h +201 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/exception_translation.h +71 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/init.h +505 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/internals.h +669 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/struct_smart_holder.h +349 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/type_caster_base.h +1598 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/typeid.h +65 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/using_smart_holder.h +22 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/detail/value_and_holder.h +78 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/eigen/common.h +9 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/eigen/matrix.h +723 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/eigen/tensor.h +521 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/eigen.h +12 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/embed.h +303 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/eval.h +156 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/functional.h +150 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/gil.h +215 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/gil_safe_call_once.h +102 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/iostream.h +265 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/numpy.h +2232 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/operators.h +202 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/options.h +92 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/pybind11.h +3442 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/pytypes.h +2655 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/stl/filesystem.h +124 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/stl.h +648 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/stl_bind.h +858 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/trampoline_self_life_support.h +60 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/type_caster_pyobject_ptr.h +61 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/typing.h +295 -0
- semiwrap-0.1.1/semiwrap/pybind11/include/pybind11/warnings.h +75 -0
- semiwrap-0.1.1/semiwrap/pyproject.py +96 -0
- semiwrap-0.1.1/semiwrap/render_meson.py +469 -0
- semiwrap-0.1.1/semiwrap/semiwrap-pybind11.pc +8 -0
- semiwrap-0.1.1/semiwrap/semiwrap.pc +9 -0
- semiwrap-0.1.1/semiwrap/semiwrap.pybind11.json +66 -0
- semiwrap-0.1.1/semiwrap/tool/__init__.py +1 -0
- semiwrap-0.1.1/semiwrap/tool/__main__.py +42 -0
- semiwrap-0.1.1/semiwrap/tool/build_dep.py +49 -0
- semiwrap-0.1.1/semiwrap/tool/create_imports.py +143 -0
- semiwrap-0.1.1/semiwrap/tool/create_yaml.py +143 -0
- semiwrap-0.1.1/semiwrap/tool/scan_headers.py +148 -0
- semiwrap-0.1.1/semiwrap/util.py +27 -0
- semiwrap-0.1.1/semiwrap/version.py +21 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software
|
|
15
|
+
without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of
|
|
29
|
+
external contributions to this project including patches, pull requests, etc.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2020-2025 Dustin Spicuzza <dustin@virtualroadside.com>, All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software
|
|
15
|
+
without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
semiwrap-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: semiwrap
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Semi-automated tool to wrap C++ code for use by python
|
|
5
|
+
Project-URL: Source code, https://github.com/robotpy/semiwrap
|
|
6
|
+
Author-email: Dustin Spicuzza <robotpy@googlegroups.com>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
License-File: LICENSE.txt
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Topic :: Software Development
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Requires-Dist: cxxheaderparser[pcpp]~=1.5
|
|
16
|
+
Requires-Dist: packaging
|
|
17
|
+
Requires-Dist: pkgconf
|
|
18
|
+
Requires-Dist: pybind11-stubgen~=2.5.1
|
|
19
|
+
Requires-Dist: pyyaml>=5.1
|
|
20
|
+
Requires-Dist: sphinxify>=0.7.3
|
|
21
|
+
Requires-Dist: tomli
|
|
22
|
+
Requires-Dist: tomli-w
|
|
23
|
+
Requires-Dist: toposort
|
|
24
|
+
Requires-Dist: typing-extensions
|
|
25
|
+
Requires-Dist: validobj~=1.2
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
semiwrap
|
|
29
|
+
========
|
|
30
|
+
|
|
31
|
+
semiwrap is a build tool that makes it simpler to wrap C/C++ libraries with
|
|
32
|
+
pybind11 by automating large portions of the wrapping process and handling some
|
|
33
|
+
of the more complex aspects of creating pybind11 based wrappers (especially with
|
|
34
|
+
trampolines to allow inheriting from C++ classes from Python).
|
|
35
|
+
|
|
36
|
+
semiwrap includes a hatchling plugin that autogenerates `meson.build` files that
|
|
37
|
+
can be built using meson, and those build files parse your wrapped headers and
|
|
38
|
+
generate/compile pybind11 based wrappers into python extension modules.
|
|
39
|
+
|
|
40
|
+
Requires Python 3.8+
|
|
41
|
+
|
|
42
|
+
Documentation
|
|
43
|
+
-------------
|
|
44
|
+
|
|
45
|
+
Documentation can be found at https://semiwrap.readthedocs.io/
|
|
46
|
+
|
|
47
|
+
Author
|
|
48
|
+
------
|
|
49
|
+
|
|
50
|
+
Dustin Spicuzza is the primary author of semiwrap.
|
|
51
|
+
|
|
52
|
+
Semiwrap is a direct decendant of the robotpy-build project, and is culmination
|
|
53
|
+
of many years of experimentation with automated wrapper generation by members of
|
|
54
|
+
the RobotPy community.
|
|
55
|
+
|
|
56
|
+
semiwrap is available under the BSD 3-clause license.
|
semiwrap-0.1.1/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
semiwrap
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
semiwrap is a build tool that makes it simpler to wrap C/C++ libraries with
|
|
5
|
+
pybind11 by automating large portions of the wrapping process and handling some
|
|
6
|
+
of the more complex aspects of creating pybind11 based wrappers (especially with
|
|
7
|
+
trampolines to allow inheriting from C++ classes from Python).
|
|
8
|
+
|
|
9
|
+
semiwrap includes a hatchling plugin that autogenerates `meson.build` files that
|
|
10
|
+
can be built using meson, and those build files parse your wrapped headers and
|
|
11
|
+
generate/compile pybind11 based wrappers into python extension modules.
|
|
12
|
+
|
|
13
|
+
Requires Python 3.8+
|
|
14
|
+
|
|
15
|
+
Documentation
|
|
16
|
+
-------------
|
|
17
|
+
|
|
18
|
+
Documentation can be found at https://semiwrap.readthedocs.io/
|
|
19
|
+
|
|
20
|
+
Author
|
|
21
|
+
------
|
|
22
|
+
|
|
23
|
+
Dustin Spicuzza is the primary author of semiwrap.
|
|
24
|
+
|
|
25
|
+
Semiwrap is a direct decendant of the robotpy-build project, and is culmination
|
|
26
|
+
of many years of experimentation with automated wrapper generation by members of
|
|
27
|
+
the RobotPy community.
|
|
28
|
+
|
|
29
|
+
semiwrap is available under the BSD 3-clause license.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.26.2", "hatch-vcs"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "semiwrap"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Semi-automated tool to wrap C++ code for use by python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "BSD-3-Clause"
|
|
12
|
+
license-files = ["LICENSE.txt", "LICENSE-pybind11.txt"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Dustin Spicuzza", email = "robotpy@googlegroups.com"},
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: BSD License",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Topic :: Software Development",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"pkgconf",
|
|
25
|
+
"sphinxify >= 0.7.3",
|
|
26
|
+
"validobj ~= 1.2",
|
|
27
|
+
"cxxheaderparser[pcpp] ~= 1.5",
|
|
28
|
+
"packaging",
|
|
29
|
+
"tomli",
|
|
30
|
+
"tomli_w",
|
|
31
|
+
"toposort",
|
|
32
|
+
"typing-extensions",
|
|
33
|
+
"pyyaml >= 5.1",
|
|
34
|
+
"pybind11-stubgen ~= 2.5.1",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.entry-points.hatch]
|
|
38
|
+
semiwrap = "semiwrap.hooks"
|
|
39
|
+
|
|
40
|
+
[project.entry-points.pkg_config]
|
|
41
|
+
semiwrap = "semiwrap"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
semiwrap = "semiwrap.tool.__main__:main"
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
"Source code" = "https://github.com/robotpy/semiwrap"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.version]
|
|
50
|
+
source = "vcs"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.sdist.hooks.vcs]
|
|
53
|
+
version-file = "src/semiwrap/version.py"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.sdist]
|
|
56
|
+
packages = ["src/semiwrap"]
|
|
57
|
+
exclude = [
|
|
58
|
+
"/src/semiwrap/pybind11"
|
|
59
|
+
]
|
|
60
|
+
[tool.hatch.build.targets.sdist.force-include]
|
|
61
|
+
"./src/semiwrap/pybind11/include" = "./semiwrap/pybind11/include"
|
|
62
|
+
"./src/semiwrap/pybind11/LICENSE" = "./LICENSE-pybind11.txt"
|
|
63
|
+
|
|
64
|
+
[tool.black]
|
|
65
|
+
target-version = ["py38"]
|
|
66
|
+
extend-exclude = '''
|
|
67
|
+
^/src/semiwrap/pybind11
|
|
68
|
+
'''
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import contextlib
|
|
3
|
+
import inspect
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RenderBuffer:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self._buffer = io.StringIO()
|
|
9
|
+
|
|
10
|
+
self._indent = ""
|
|
11
|
+
self._indentlen = 0
|
|
12
|
+
|
|
13
|
+
def getvalue(self) -> str:
|
|
14
|
+
return self._buffer.getvalue()
|
|
15
|
+
|
|
16
|
+
def rel_indent(self, spaces: int):
|
|
17
|
+
self._indentlen += spaces
|
|
18
|
+
self._indent = " " * self._indentlen
|
|
19
|
+
|
|
20
|
+
@contextlib.contextmanager
|
|
21
|
+
def indent(self, spaces: int = 2):
|
|
22
|
+
self._indentlen += spaces
|
|
23
|
+
self._indent = " " * self._indentlen
|
|
24
|
+
try:
|
|
25
|
+
yield
|
|
26
|
+
finally:
|
|
27
|
+
self._indentlen -= spaces
|
|
28
|
+
self._indent = " " * self._indentlen
|
|
29
|
+
|
|
30
|
+
def writeln(self, s: str = ""):
|
|
31
|
+
if not s:
|
|
32
|
+
self._buffer.write("\n")
|
|
33
|
+
else:
|
|
34
|
+
for line in s.splitlines(False):
|
|
35
|
+
if line:
|
|
36
|
+
self._buffer.write(f"{self._indent}{line}\n")
|
|
37
|
+
else:
|
|
38
|
+
self._buffer.write("\n")
|
|
39
|
+
|
|
40
|
+
def write_trim(self, s: str):
|
|
41
|
+
for line in inspect.cleandoc(s).splitlines(False):
|
|
42
|
+
if line:
|
|
43
|
+
self._buffer.write(f"{self._indent}{line}\n")
|
|
44
|
+
else:
|
|
45
|
+
self._buffer.write("\n")
|