Skip to content

Commit ae2bb8e

Browse files
README.md: Fix Markdown format for linting and update it
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 5c544ac commit ae2bb8e

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

README.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
# Common XenServer/XCP-ng Python classes
2+
13
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
24
[![](https://img.shields.io/badge/python-2.7_%7C_3.6_%7C_3.7_%7C_3.8_%7C_3.9_%7C_3.10_%7C_3.11+-blue.svg)](https://www.python.org/downloads/)
35
[![codecov](https://codecov.io/gh/xenserver/python-libs/branch/master/graph/badge.svg?token=6WKVLDXJFN)](https://codecov.io/gh/xenserver/python-libs)
46
[![](https://img.shields.io/badge/License-BSD--2--Cause%20%26%20MIT-brightgreen)](https://github.com/xenserver/python-libs/blob/master/LICENSE)
57

6-
# Common XenServer/XCP-ng Python classes
7-
88
The `xcp` directory contains the Common XenServer and XCP-ng Python packages.
99
They are intented for use in XenServer and XCP-ng Dom0 only and deal with logging,
1010
Hardware/PCI, networking, and other Dom0 tasks.
@@ -18,6 +18,8 @@ It depends on `six`, and on Python 2.7, also `configparser` and `pyliblzma`.
1818

1919
## Test-driven Development (TDD) Model
2020

21+
Please see [CONTRIBUTING.md] for installing a local development environment.
22+
2123
This package has CI which can be run locally but is also run in GitHub CI to ensure
2224
Test-driven development.
2325

@@ -81,7 +83,7 @@ For the installation of the general development dependencies, visit [INSTALL.md]
8183

8284
The list of `virtualenvs` configured in tox can be shown using this command: `tox -av`
8385

84-
```yaml
86+
```ml
8587
$ tox -av
8688
default environments:
8789
py36-lint -> Run in a py36 virtualenv: Run pylint and fail on warnings remaining on lines in the diff to master
@@ -114,17 +116,20 @@ The goal or final benefit would be to have it to ensure internal type correctnes
114116
and code quality but also to use static analysis to check the interoperability with
115117
the calling code.
116118

117-
## Type annotations: Use Type comments for now!
119+
## Type annotations: Use Type comments for now
118120

119121
Python2.7 can't support the type annotation syntax, but until all users are migrated,
120122
annotations in comments (type comments) can be used. They are supported by
121123
tools like `mypy` and `pyright` (VS Code):
122124

123-
Quoting from https://stackoverflow.com/questions/53306458/python-3-type-hints-in-python-2:
125+
Quoting from <https://stackoverflow.com/questions/53306458/python-3-type-hints-in-python-2>:
124126

125127
> Function annotations were introduced in [PEP 3107](https://www.python.org/dev/peps/pep-3107/) for Python 3.0. The usage of annotations as type hints was formalized in in [PEP 484](https://www.python.org/dev/peps/pep-0484/) for Python 3.5+.
126128
>
127-
> Any version before 3.0 then will not support the syntax you are using for type hints at all. However, PEP 484 [offers a workaround](https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code), which some editors may choose to honor. In your case, the hints would look like this:
129+
> Python < 3.0 does support the type hints syntax, but
130+
> [PEP 484](https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code)
131+
> introduces type comments that are equally supported and are otherwise ignored.
132+
These type comments look like this:
128133

129134
```py
130135
def get_default_device(use_gpu=True):
@@ -170,30 +175,19 @@ xcp/xmlunwrap.py
170175
Completed in 0.604sec
171176
```
172177

173-
See https://github.com/xenserver/python-libs/pull/23 for the context of this example.
178+
See <https://github.com/xenserver/python-libs/pull/23> for the context of this example.
174179

175-
## Special open TODOs:
180+
## Guidelines
176181

177182
Charset encoding/string handling:
178-
See [README-Unicode.md](README-Unicode.md) for details:
179-
180-
- What's more: When code is called from a xapi plugin (such as ACK), when such code
181-
attempts to read text files like the `pciids` file, and there is a Unicode char
182-
it int, and the locale is not set up to be UTF-8 (because xapi plugins are started
183-
from xapi), the UTF-8 decoder has to be explicitly enabled for these files,
184-
bese by adding `encoding="utf-8"` to the arguments of these specific `open()` calls,
185-
to have valid Unicode text strings, e.g. `xcp.pci`, for regular text processing.
186-
- TODO: More to be opened for all remaining `open()` and `Popen()` users,
187-
as well as ensuring that users of `urllib` are able to work with they bytes
188-
it returns (there is no option to use text mode, data may be gzip-encoded!)
183+
See [README-Unicode.md](README-Unicode.md) for details on Unicode support.
189184

190185
## Users
191186

192-
- https://github.com/xenserver/host-installer
193-
- /opt/xensource/installer/ (has copies of `cpiofile.py`, `repository.py` (with `accessor.py`)
194-
- https://github.com/xcp-ng-rpms/host-upgrade-plugin ([koji](https://koji.xcp-ng.org/packageinfo?packageID=104)):
187+
- [host-installer](https://github.com/xenserver/host-installer)
188+
- [host-upgrade-plugin](https://github.com/xcp-ng-rpms/host-upgrade-plugin) ([koji](https://koji.xcp-ng.org/packageinfo?packageID=104)):
195189
- /etc/xapi.d/plugins/prepare_host_upgrade.py
196-
- https://github.com/xapi-project/xen-api (`xapi-core.rpm` and `xenopsd.rpm`)
190+
- [xapi](https://github.com/xapi-project/xen-api) (`xapi-core.rpm` and `xenopsd.rpm`)
197191
- /etc/xapi.d/extensions/pool_update.apply
198192
- /etc/xapi.d/extensions/pool_update.precheck
199193
- /etc/xapi.d/plugins/disk-space
@@ -206,16 +200,16 @@ See [README-Unicode.md](README-Unicode.md) for details:
206200
- xenserver-release-config/[xcp-ng-release-config](https://koji.xcp-ng.org/rpminfo?rpmID=10250)
207201
- /opt/xensource/libexec/fcoe_driver
208202
- /opt/xensource/libexec/xen-cmdline
209-
- https://github.com/xcp-ng-rpms/interface-rename:
203+
- <https://github.com/xcp-ng-rpms/interface-rename>
210204
- /etc/sysconfig/network-scripts/interface-rename.py
211205
- /opt/xensource/bin/interface-rename
212206
- pvsproxy (Proprietary)
213207
- /usr/libexec/xapi-storage-script/volume/org.xen.xapi.storage.tmpfs/memoryhelper.py
214-
- https://github.com/xenserver/linux-guest-loader (not installed by default anymore)
208+
- <https://github.com/xenserver/linux-guest-loader> (not installed by default anymore)
215209
- /opt/xensource/libexec/eliloader.py
216-
- https://github.com/xcp-ng-rpms/vcputune
210+
- <https://github.com/xcp-ng-rpms/vcputune>
217211
- /opt/xensource/bin/host-cpu-tune
218-
- The ACK xenapi plugin see: https://github.com/xenserver/python-libs/pull/21
212+
- The ACK xapi plugin. See: <https://github.com/xenserver/python-libs/pull/21>
219213

220214
Verification:
221215

0 commit comments

Comments
 (0)