├── test ├── __init__.py ├── test_main.py ├── test_config.py ├── test_pm.py └── test_mangle.py ├── .gitignore ├── .github ├── FUNDING.yml └── workflows │ └── ci.yaml ├── flaggie ├── __init__.py ├── config.py ├── pm.py ├── __main__.py └── mangle.py ├── tox.ini ├── COPYING └── pyproject.toml /test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | /.tox/ 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: mgorny 2 | github: [mgorny] 3 | -------------------------------------------------------------------------------- /flaggie/__init__.py: -------------------------------------------------------------------------------- 1 | """CLI mangler for Portage package.* configuration files""" 2 | 3 | __version__ = "0.99.8" 4 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = qa,py39,py310,py311,pypy3 3 | isolated_build = True 4 | 5 | [testenv] 6 | deps = 7 | mypy 8 | extras = 9 | test 10 | commands = 11 | pytest -vv {posargs:test} 12 | mypy {posargs:flaggie test} 13 | 14 | [testenv:qa] 15 | skip_install = true 16 | deps = 17 | pycodestyle 18 | pyflakes 19 | commands = 20 | pyflakes {posargs:flaggie test} 21 | pycodestyle {posargs:flaggie test} 22 | 23 | [testenv:upload] 24 | skip_install = true 25 | deps = 26 | build 27 | twine 28 | commands = 29 | python -m build -s -w 30 | twine upload dist/* 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | jobs: 4 | ci: 5 | strategy: 6 | matrix: 7 | python-version: ["3.9", "3.10", "3.11", "3.12-dev", "pypy-3.9"] 8 | fail-fast: false 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v2 13 | - name: Set up Python 14 | uses: actions/setup-python@v3 15 | with: 16 | python-version: ${{ matrix.python-version }} 17 | - name: Install tox 18 | run: pip install tox 19 | - name: Test using tox 20 | run: tox -e py 21 | qa: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v2 26 | - name: Set up Python 27 | uses: actions/setup-python@v3 28 | with: 29 | python-version: "3.11" 30 | - name: Install tox 31 | run: pip install tox 32 | - name: Test using tox 33 | run: tox -e qa 34 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 Michał Górny 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=3.2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "flaggie" 7 | authors = [{name = "Michał Górny", email = "mgorny@gentoo.org"}] 8 | license = {file = "COPYING"} 9 | classifiers = ["License :: OSI Approved :: MIT License"] 10 | dynamic = ["version", "description"] 11 | requires-python = ">=3.9" 12 | dependencies = [ 13 | "more-itertools", 14 | ] 15 | 16 | [project.optional-dependencies] 17 | package-manager = [ 18 | "gentoopm >= 0.5", 19 | ] 20 | pretty-log = [ 21 | "rich", 22 | ] 23 | test = [ 24 | "pytest", 25 | ] 26 | 27 | [project.scripts] 28 | flaggie = "flaggie.__main__:entry_point" 29 | 30 | [project.urls] 31 | Homepage = "https://github.com/projg2/flaggie/" 32 | 33 | [tool.flit.sdist] 34 | include = [ 35 | "test", 36 | "tox.ini", 37 | ] 38 | 39 | [tool.mypy] 40 | disallow_untyped_defs = true 41 | no_implicit_optional = true 42 | 43 | [[tool.mypy.overrides]] 44 | module = [ 45 | "test.*", 46 | ] 47 | # requiring explicit types for all test methods would be cumbersome 48 | disallow_untyped_defs = false 49 | check_untyped_defs = true 50 | 51 | [[tool.mypy.overrides]] 52 | module = [ 53 | "gentoopm.*", 54 | "rich.*", 55 | ] 56 | ignore_missing_imports = true 57 | 58 | [tool.pytest.ini_options] 59 | addopts = "--log-level=debug" 60 | testpaths = [ 61 | "test", 62 | ] 63 | -------------------------------------------------------------------------------- /test/test_main.py: -------------------------------------------------------------------------------- 1 | # (c) 2023 Michał Górny 2 | # Released under the terms of the MIT license 3 | 4 | import argparse 5 | 6 | import pytest 7 | 8 | from flaggie.__main__ import (split_arg_sets, split_op, 9 | namespace_into_token_group, 10 | ) 11 | from flaggie.config import TokenType 12 | 13 | 14 | @pytest.mark.parametrize( 15 | "args,expected", 16 | [(["+foo", "-bar"], [([], ["+foo", "-bar"])]), 17 | (["dev-foo/bar", "+foo"], [(["dev-foo/bar"], ["+foo"])]), 18 | (["dev-foo/bar", "baz", "-foo"], 19 | [(["dev-foo/bar", "baz"], ["-foo"])]), 20 | (["+foo", "dev-foo/*", "-foo"], 21 | [([], ["+foo"]), (["dev-foo/*"], ["-foo"])]), 22 | ([">=dev-foo/bar-11-r1", "+foo"], [([">=dev-foo/bar-11-r1"], ["+foo"])]), 23 | (["