a checkpoint fails if there are already existing checkoints that
Found using the codespell
.
This a follow up to !1246
@thaller found out that build was failing on EPEL7.
On python2 the following error is raised:
LookupError: unknown encoding: unicode
Seems like unicode
is a correct encoding in Python 3 but not 2.
Fix:
utf-8
I tested element tree on python2 and it utf-8
seems to work. (I can't test entire build as it would require me to install too many Python 2 dependencies)
epel7
should have python 3 available.
Also it is possible to switch file encoding to bytes which should make it compatible with python 2. It seems like the issue is unknown encoding: unicode
Also there is no EPEL 7 in CI.
I realized that there is not a single print call in the file...
However, I also added the unicode_literals
future import so the code is more consistent between versions.
I think I deviated a bit from original merge request.
Should I rename this one so it can be merged under something like "Modernize generate-docs-nm-settings-docs-gir.py"
I can also do the same modernization process to other python tools files.
But let's not do it as this commit. It requires at least a NEWS file entry, possibly drop all the from future import, and other compat code.
Sure. I will edit the commits.
If gitlab-ci passes, ok, then it's fine.
I've started some very old distros on CI: https://gitlab.freedesktop.org/igo95862/NetworkManager/-/pipelines/599544
EDIT: they all passed
The generated XML is functionally same.
Sample:
nm-setting-docs><setting name="connection" description="General Connection Profile Settings" name_upper="CONNECTION"><property name="auth-retries" name_upper="AUTH_RETRIES" type="int32" description="The number of retries for the authentication. Zero means to try indefinitely; -1 means to use a global default. If the global default is not set, the authentication retries for 3 times before failing the connection. Currently, this only applies to 802-1x authentication." default="-1" />
ElementTree is used instead of manually writing XML by hand which is very error prone and difficult to modify.
Isn't Python2 already dropped?
Meson straight up selects python3: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/meson.build#L875
Autotools either use the passed environment variable PYTHON
or defaults to Python3: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/configure.ac#L1271
Unless you want to make it possible to use Python 2 by explicitly passing it. Is there any distro still in use that does not ship python3?
I can also return that future import.
I made the generate-docs-nm-settings-docs-gir.py
use ElementTree to write XML.
It is much easier to modify now by just inserting new nodes.
However, there are few differences.
First it is not indented anymore. There is ElementTree.indent
but it is only available from Python 3.9. (by the way what is the minimum Python version) There is also an option to use ElementTree.tostringlist
to indent attributes more manually.
Second, I omited the <!DOCTYPE nm-setting-docs [<!ENTITY quot """>
header. It can be added back.
@lkundrak I started with modernization of existing script.
My next plan is to replace manual writing with outfile.write
with ElemenTree methods.
Ok I am going to rewrite the generate-docs-nm-settings-docs-gir.py
a bit or it is going to become maintenance nightmare in the future.
@lkundrak What do you think about preserving the current "description"
attribute as is and adding the ,para>
on top of that?
I should preserve compatibility with everything but bloat the generated XML. (does that matter)
I'm wondering if you'd like to give it a shot? Otherwise I guess I can take a look at some point.
Ok. I will try.