Package bitmask using hatch
This commit is contained in:
parent
edc9c4d353
commit
54bd28795b
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
__pycache__/
|
||||
dist
|
||||
tags
|
||||
.coverage
|
||||
|
45
README.md
Normal file
45
README.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Bitmask
|
||||
|
||||
Implementation of a Bitmask class in Python, allowing easy manipulation of EnumFlag values.
|
||||
|
||||
## Features
|
||||
|
||||
* create bitmasks from any EnumFlag type
|
||||
|
||||
* simple "flag in Bitmask" syntax
|
||||
|
||||
* bitwise operations, e.g. AND (&), OR (|), XOR (^)
|
||||
|
||||
* assignment with operators (+=, -=, &=, etc.)
|
||||
|
||||
* convenience functions like Bitmask.add(), or Bitmask.discard()
|
||||
|
||||
For development and tinkering:
|
||||
|
||||
* included unit tests
|
||||
|
||||
* ample documentation and examples in code
|
||||
|
||||
## Example usage
|
||||
|
||||
```python
|
||||
from bitmask import Bitmask
|
||||
from enum import IntFlag
|
||||
|
||||
class Desc(IntFlag):
|
||||
SMALL = 1
|
||||
ROUND = 1 << 1
|
||||
FUNKY = 1 << 2
|
||||
LARGE = 1 << 3
|
||||
|
||||
marble = Bitmask(Desc, Desc.SMALL, Desc.ROUND, Desc.FUNKY)
|
||||
|
||||
Desc.SMALL in marble
|
||||
>>> True
|
||||
|
||||
Desc.LARGE in marble
|
||||
>>> False
|
||||
|
||||
Bitmask(Desc, Desc.SMALL, Desc.ROUND) in marble
|
||||
>>> True
|
||||
```
|
4
bitmask/__about__.py
Normal file
4
bitmask/__about__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# Copyright 2022 dogeystamp <dogeystamp@disroot.org>
|
||||
# See LICENSE file for more details.
|
||||
|
||||
__version__ = "0.0.1"
|
4
bitmask/__init__.py
Normal file
4
bitmask/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# Copyright 2022 dogeystamp <dogeystamp@disroot.org>
|
||||
# See LICENSE file for more details.
|
||||
|
||||
from .bitmask import Bitmask
|
@ -1,26 +1,5 @@
|
||||
# Copyright 2022 dogeystamp <dogeystamp@disroot.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# Copyright 2022 dogeystamp <dogeystamp@disroot.org>
|
||||
# See LICENSE file for more details.
|
||||
|
||||
"""Utilities for manipulating bitmasks."""
|
||||
|
@ -1,3 +1,6 @@
|
||||
# Copyright 2022 dogeystamp <dogeystamp@disroot.org>
|
||||
# See LICENSE file for more details.
|
||||
|
||||
from bitmask import Bitmask
|
||||
from enum import IntFlag
|
||||
import unittest
|
63
pyproject.toml
Normal file
63
pyproject.toml
Normal file
@ -0,0 +1,63 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "bitmask"
|
||||
description = 'Featureful bitmask implementation.'
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
license = "MIT"
|
||||
keywords = []
|
||||
authors = [
|
||||
{ name = "dogeystamp", email = "dogeystamp@disroot.org" },
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
dependencies = []
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://github.com/dogeystamp/bitmask#readme"
|
||||
Issues = "https://github.com/dogeystamp/bitmask/issues"
|
||||
Source = "https://github.com/dogeystamp/bitmask"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "bitmask/__about__.py"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
[tool.hatch.build.targets.wheel]
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
dependencies = [
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
]
|
||||
[tool.hatch.envs.default.scripts]
|
||||
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=bitmask --cov=tests"
|
||||
no-cov = "cov --no-cov"
|
||||
|
||||
[[tool.hatch.envs.test.matrix]]
|
||||
python = ["37", "38", "39", "310"]
|
||||
|
||||
[tool.coverage.run]
|
||||
branch = true
|
||||
parallel = true
|
||||
omit = [
|
||||
"bitmask/__about__.py",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_lines = [
|
||||
"no cov",
|
||||
"if __name__ == .__main__.:",
|
||||
"if TYPE_CHECKING:",
|
||||
]
|
Loading…
Reference in New Issue
Block a user