begin subparser integration

This commit is contained in:
Sam G. 2024-05-18 15:35:10 -07:00
parent d2c9ff9c06
commit 888bb52d23
10 changed files with 173 additions and 56 deletions

18
.gitignore vendored
View File

@ -1,2 +1,18 @@
docs/_build # generic py
__pycache__/
.pytest_cache/
*.egg-info/
.ipynb_checkpoints/
.pytest_cache/
.python-version .python-version
# vendor and build files
dist/
build/
docs/_autoref/
docs/_autosummary/
docs/_build/
# local
notebooks/
/Makefile

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2024 Sam Griesemer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
TODO.md Normal file
View File

@ -0,0 +1,5 @@
- Push scheme generation to `~/.config/autoconf`
- Copy default app registry to the config location
- Formalize the theme spec (JSON) and `autoconf gen` to produce color configs
- Likely need to formalize the `sync.sh` script logic better, possibly associated directly
with registry TOML

0
autoconf/__init__.py Normal file
View File

23
autoconf/__main__.py Normal file
View File

@ -0,0 +1,23 @@
import argparse
from gen_theme import add_gen_subparser
from set_theme import add_set_subparser
parser = argparse.ArgumentParser(
'autoconf',
description='Generate theme files for various applications. Uses a template (in TOML ' \
+ 'format) to map application-specific config keywords to colors (in JSON ' \
+ 'format).'
)
subparsers = parser.get_subparsers()
add_gen_subparser(subparsers)
add_set_subparser(subparsers)
args = parser.parse_args()
if __name__ == '__main__':
if 'func' in args:
args.func(args)
else:
parser.print_help()

View File

@ -9,33 +9,36 @@ def get_running_path():
return Path(calling_module.__file__).parent return Path(calling_module.__file__).parent
parser = argparse.ArgumentParser( def add_gen_subparser(subparsers):
parser = subparsers.add_parser(
'gen',
description='Generate theme files for various applications. Uses a template (in TOML ' \ description='Generate theme files for various applications. Uses a template (in TOML ' \
+ 'format) to map application-specific config keywords to colors (in JSON ' \ + 'format) to map application-specific config keywords to colors (in JSON ' \
+ 'format).' + 'format).'
) )
parser.add_argument( parser.add_argument(
'-a', '--app', '-a', '--app',
required=True, required=True,
help='Application target for theme. Supported: ["kitty"]' help='Application target for theme. Supported: ["kitty"]'
) )
parser.add_argument( parser.add_argument(
'-p', '--palette', '-p', '--palette',
required=True, required=True,
help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".' help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".'
) )
parser.add_argument( parser.add_argument(
'-t', '--template', '-t', '--template',
default=None, default=None,
help='Path to TOML template file. If omitted, app\'s default template path is used.' \ help='Path to TOML template file. If omitted, app\'s default template path is used.' \
+ 'If a directory is provided, all TOML files in the folder will be used.' + 'If a directory is provided, all TOML files in the folder will be used.'
) )
parser.add_argument( parser.add_argument(
'-o', '--output', '-o', '--output',
default=None, default=None,
help='Output file path for theme. If omitted, app\'s default theme output path is used.' help='Output file path for theme. If omitted, app\'s default theme output path is used.'
) )
args = parser.parse_args() parser.set_defaults(func=generate_theme_files)
# separation sequences to use base on app # separation sequences to use base on app
app_sep_map = { app_sep_map = {
@ -104,5 +107,3 @@ def generate_theme_files():
output_file.write_text('\n'.join(output_lines)) output_file.write_text('\n'.join(output_lines))
print(f'[{len(output_lines)}] lines written to [{output_file}] for app [{theme_app}]') print(f'[{len(output_lines)}] lines written to [{output_file}] for app [{theme_app}]')
if __name__ == '__main__':
generate_theme_files()

View File

@ -8,29 +8,30 @@ from pathlib import Path
from colorama import Fore from colorama import Fore
def add_set_subparser(subparsers):
parser = argparse.ArgumentParser( parser = subparsers.add_parser(
'set',
description='Generate theme files for various applications. Uses a template (in TOML ' \ description='Generate theme files for various applications. Uses a template (in TOML ' \
+ 'format) to map application-specific config keywords to colors (in JSON ' \ + 'format) to map application-specific config keywords to colors (in JSON ' \
+ 'format).' + 'format).'
) )
parser.add_argument( parser.add_argument(
'-p', '--palette', '-p', '--palette',
required=True, required=True,
help='Palette name, must match a folder in themes/' help='Palette name, must match a folder in themes/'
) )
parser.add_argument( parser.add_argument(
'-s', '--scheme', '-s', '--scheme',
required=True, required=True,
help='Preferred lightness scheme, either "light" or "dark".' help='Preferred lightness scheme, either "light" or "dark".'
) )
parser.add_argument( parser.add_argument(
'-a', '--app', '-a', '--app',
required=True, required=True,
help='Application target for theme. App must be present in the registry. ' \ help='Application target for theme. App must be present in the registry. ' \
+ 'Use "*" to apply to all registered apps' + 'Use "*" to apply to all registered apps'
) )
args = parser.parse_args() parser.set_defaults(func=update_theme_settings)
def get_running_path(): def get_running_path():

52
pyproject.toml Normal file
View File

@ -0,0 +1,52 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-git-versioning>=2.0,<3"]
build-backend = "setuptools.build_meta"
[tool.setuptools-git-versioning]
enabled = true
[project]
name = "co3"
description = "Lightweight Python ORM for hierarchical storage management"
readme = "README.md"
requires-python = ">=3.12"
dynamic = ["version"]
#license = {file = "LICENSE"}
authors = [
{ name="Sam Griesemer", email="samgriesemer+git@gmail.com" },
]
keywords = ["database", "orm"]
classifiers = [
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
]
dependencies = [
"tqdm",
"wcmatch",
"numpy",
"sqlalchemy",
"colorama",
]
[project.optional-dependencies]
tests = ["pytest"]
docs = [
"sphinx",
"sphinx-togglebutton",
"sphinx-autodoc-typehints",
"furo",
"myst-parser",
]
[project.urls]
Homepage = "https://doc.olog.io/co3"
Documentation = "https://doc.olog.io/co3"
Repository = "https://git.olog.io/olog/co3"
Issues = "https://git.olog.io/olog/co3/issues"
[tool.setuptools.packages.find]
include = ["co3*"] # pattern to match package names

View File

@ -1,3 +0,0 @@
sphinx
furo
myst-parser