Name | decoratools JSON |
Version |
0.0.19
JSON |
| download |
home_page | |
Summary | Collection of useful decorators |
upload_time | 2024-01-27 21:45:53 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.11 |
license | MIT |
keywords |
decorator
utility
library
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Collection of useful decorators
-----
# Installation
```bash
pip install decoratools
```
# Usage
## `capi`
Interface with [`statx(2)`](https://man7.org/linux/man-pages/man2/statx.2.html):
```python
import ctypes
from argparse import ArgumentParser
from decoratools.capi import ARRAY, POINTER, structure, unwraps
LIBC = ctypes.CDLL("libc.so.6")
AT_FDCDW = -100
STATX_BASIC_STATS = 0x000007FF
@structure
class StatxTimestamp:
tv_sec: ctypes.c_int64
tv_nsec: ctypes.c_uint32
__statx_timestamp_pad1: ctypes.c_int32
@structure
class Statx:
stx_mask: ctypes.c_uint32
stx_blksize: ctypes.c_uint32
stx_attributes: ctypes.c_uint64
stx_nlink: ctypes.c_uint32
stx_uid: ctypes.c_uint32
stx_gid: ctypes.c_uint32
stx_mode: ctypes.c_uint16
__statx_pad1: ctypes.c_uint16
stx_ino: ctypes.c_uint64
stx_size: ctypes.c_uint64
stx_blocks: ctypes.c_uint64
stx_attributes_mask: ctypes.c_uint64
stx_atime: StatxTimestamp
stx_btime: StatxTimestamp
stx_ctime: StatxTimestamp
stx_mtime: StatxTimestamp
stx_rdev_major: ctypes.c_uint32
stx_rdev_minor: ctypes.c_uint32
stx_dev_major: ctypes.c_uint32
stx_dev_minor: ctypes.c_uint32
stx_mnt_id: ctypes.c_uint64
stx_dio_mem_align: ctypes.c_uint32
stx_dio_offset_align: ctypes.c_uint32
__statx_pad2: ARRAY[ctypes.c_uint64, 12]
@unwraps(LIBC.statx)
def statx(
dirfd: ctypes.c_int, pathname: ctypes.c_char_p, flags: ctypes.c_int, mask: ctypes.c_int, statxbuf: POINTER[Statx]
) -> int:
...
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("path", help="path to statx")
args = parser.parse_args()
statxbuf = Statx()
rc = statx(AT_FDCDW, args.path.encode(), 0, STATX_BASIC_STATS, ctypes.byref(statxbuf))
if rc != 0:
raise RuntimeError("statx: failed")
print(statxbuf)
```
```console
$ python statx.py /dev/null
Statx(stx_mask=6143, stx_blksize=4096, stx_attributes=0, stx_nlink=1, stx_uid=0, stx_gid=0, stx_mode=8630, _Statx__statx_pad1=0, stx_ino=4, stx_size=0, stx_blocks=0, stx_attributes_mask=2109552, stx_atime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_btime=StatxTimestamp(tv_sec=0, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_ctime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_mtime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_rdev_major=1, stx_rdev_minor=3, stx_dev_major=0, stx_dev_minor=5, stx_mnt_id=22, stx_dio_mem_align=0, stx_dio_offset_align=0, _Statx__statx_pad2=<decoratools.capi.c_ulong_Array_12 object at 0x7efe94be0a70>)
```
Raw data
{
"_id": null,
"home_page": "",
"name": "decoratools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "decorator,utility,library",
"author": "",
"author_email": "Quentin Bouget <ypsah@devyard.org>",
"download_url": "https://files.pythonhosted.org/packages/e3/87/e43da75f7cfcebd1fe7265fc9dc7ce9db5d44ce83bd25f2e7c361c33b220/decoratools-0.0.19.tar.gz",
"platform": null,
"description": "Collection of useful decorators\n\n-----\n\n# Installation\n\n```bash\npip install decoratools\n```\n\n# Usage\n\n## `capi`\n\nInterface with [`statx(2)`](https://man7.org/linux/man-pages/man2/statx.2.html):\n\n```python\nimport ctypes\nfrom argparse import ArgumentParser\n\nfrom decoratools.capi import ARRAY, POINTER, structure, unwraps\n\nLIBC = ctypes.CDLL(\"libc.so.6\")\nAT_FDCDW = -100\nSTATX_BASIC_STATS = 0x000007FF\n\n\n@structure\nclass StatxTimestamp:\n tv_sec: ctypes.c_int64\n tv_nsec: ctypes.c_uint32\n __statx_timestamp_pad1: ctypes.c_int32\n\n\n@structure\nclass Statx:\n stx_mask: ctypes.c_uint32\n stx_blksize: ctypes.c_uint32\n stx_attributes: ctypes.c_uint64\n stx_nlink: ctypes.c_uint32\n stx_uid: ctypes.c_uint32\n stx_gid: ctypes.c_uint32\n stx_mode: ctypes.c_uint16\n __statx_pad1: ctypes.c_uint16\n stx_ino: ctypes.c_uint64\n stx_size: ctypes.c_uint64\n stx_blocks: ctypes.c_uint64\n stx_attributes_mask: ctypes.c_uint64\n\n stx_atime: StatxTimestamp\n stx_btime: StatxTimestamp\n stx_ctime: StatxTimestamp\n stx_mtime: StatxTimestamp\n\n stx_rdev_major: ctypes.c_uint32\n stx_rdev_minor: ctypes.c_uint32\n\n stx_dev_major: ctypes.c_uint32\n stx_dev_minor: ctypes.c_uint32\n\n stx_mnt_id: ctypes.c_uint64\n\n stx_dio_mem_align: ctypes.c_uint32\n stx_dio_offset_align: ctypes.c_uint32\n\n __statx_pad2: ARRAY[ctypes.c_uint64, 12]\n\n\n@unwraps(LIBC.statx)\ndef statx(\n dirfd: ctypes.c_int, pathname: ctypes.c_char_p, flags: ctypes.c_int, mask: ctypes.c_int, statxbuf: POINTER[Statx]\n) -> int:\n ...\n\n\nif __name__ == \"__main__\":\n parser = ArgumentParser()\n parser.add_argument(\"path\", help=\"path to statx\")\n args = parser.parse_args()\n\n statxbuf = Statx()\n rc = statx(AT_FDCDW, args.path.encode(), 0, STATX_BASIC_STATS, ctypes.byref(statxbuf))\n if rc != 0:\n raise RuntimeError(\"statx: failed\")\n print(statxbuf)\n```\n\n```console\n$ python statx.py /dev/null\nStatx(stx_mask=6143, stx_blksize=4096, stx_attributes=0, stx_nlink=1, stx_uid=0, stx_gid=0, stx_mode=8630, _Statx__statx_pad1=0, stx_ino=4, stx_size=0, stx_blocks=0, stx_attributes_mask=2109552, stx_atime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_btime=StatxTimestamp(tv_sec=0, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_ctime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_mtime=StatxTimestamp(tv_sec=1672527600, tv_nsec=0, _StatxTimestamp__statx_timestamp_pad1=0), stx_rdev_major=1, stx_rdev_minor=3, stx_dev_major=0, stx_dev_minor=5, stx_mnt_id=22, stx_dio_mem_align=0, stx_dio_offset_align=0, _Statx__statx_pad2=<decoratools.capi.c_ulong_Array_12 object at 0x7efe94be0a70>)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Collection of useful decorators",
"version": "0.0.19",
"project_urls": {
"homepage": "https://gitlab.com/ypsah/decoratools",
"repository": "https://gitlab.com/ypsah/decoratools"
},
"split_keywords": [
"decorator",
"utility",
"library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "29b48b240d49ecc5794dd876164c6f3b09fe6e57ef8446981a8d329b7e003033",
"md5": "eb15378163b55c389ac467426496f286",
"sha256": "9b6934ee22e40565840470e9c80ed027319d86d0c46f98e1d1208d8718e89216"
},
"downloads": -1,
"filename": "decoratools-0.0.19-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb15378163b55c389ac467426496f286",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 5216,
"upload_time": "2024-01-27T21:45:52",
"upload_time_iso_8601": "2024-01-27T21:45:52.254962Z",
"url": "https://files.pythonhosted.org/packages/29/b4/8b240d49ecc5794dd876164c6f3b09fe6e57ef8446981a8d329b7e003033/decoratools-0.0.19-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e387e43da75f7cfcebd1fe7265fc9dc7ce9db5d44ce83bd25f2e7c361c33b220",
"md5": "5f2e0af131b8c3f3e18152c972c530d3",
"sha256": "62b84a83cb6c701f8ae5652e6c1a45dc8f3785bcc5909d0cdcce69250893c61e"
},
"downloads": -1,
"filename": "decoratools-0.0.19.tar.gz",
"has_sig": false,
"md5_digest": "5f2e0af131b8c3f3e18152c972c530d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 5144,
"upload_time": "2024-01-27T21:45:53",
"upload_time_iso_8601": "2024-01-27T21:45:53.826056Z",
"url": "https://files.pythonhosted.org/packages/e3/87/e43da75f7cfcebd1fe7265fc9dc7ce9db5d44ce83bd25f2e7c361c33b220/decoratools-0.0.19.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-27 21:45:53",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "ypsah",
"gitlab_project": "decoratools",
"lcname": "decoratools"
}