begin subparser integration
This commit is contained in:
parent
d2c9ff9c06
commit
888bb52d23
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,2 +1,18 @@
|
||||
docs/_build
|
||||
# generic py
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
*.egg-info/
|
||||
.ipynb_checkpoints/
|
||||
.pytest_cache/
|
||||
.python-version
|
||||
|
||||
# vendor and build files
|
||||
dist/
|
||||
build/
|
||||
docs/_autoref/
|
||||
docs/_autosummary/
|
||||
docs/_build/
|
||||
|
||||
# local
|
||||
notebooks/
|
||||
/Makefile
|
||||
|
22
LICENSE
Normal file
22
LICENSE
Normal 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
5
TODO.md
Normal 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
0
autoconf/__init__.py
Normal file
23
autoconf/__main__.py
Normal file
23
autoconf/__main__.py
Normal 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()
|
@ -9,33 +9,36 @@ def get_running_path():
|
||||
return Path(calling_module.__file__).parent
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||
+ 'format).'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-a', '--app',
|
||||
required=True,
|
||||
help='Application target for theme. Supported: ["kitty"]'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--palette',
|
||||
required=True,
|
||||
help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-t', '--template',
|
||||
default=None,
|
||||
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.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
default=None,
|
||||
help='Output file path for theme. If omitted, app\'s default theme output path is used.'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
def add_gen_subparser(subparsers):
|
||||
parser = subparsers.add_parser(
|
||||
'gen',
|
||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||
+ 'format).'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-a', '--app',
|
||||
required=True,
|
||||
help='Application target for theme. Supported: ["kitty"]'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--palette',
|
||||
required=True,
|
||||
help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-t', '--template',
|
||||
default=None,
|
||||
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.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
default=None,
|
||||
help='Output file path for theme. If omitted, app\'s default theme output path is used.'
|
||||
)
|
||||
parser.set_defaults(func=generate_theme_files)
|
||||
|
||||
|
||||
# separation sequences to use base on app
|
||||
app_sep_map = {
|
||||
@ -104,5 +107,3 @@ def generate_theme_files():
|
||||
output_file.write_text('\n'.join(output_lines))
|
||||
print(f'[{len(output_lines)}] lines written to [{output_file}] for app [{theme_app}]')
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate_theme_files()
|
||||
|
@ -8,29 +8,30 @@ from pathlib import Path
|
||||
|
||||
from colorama import Fore
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||
+ 'format).'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--palette',
|
||||
required=True,
|
||||
help='Palette name, must match a folder in themes/'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-s', '--scheme',
|
||||
required=True,
|
||||
help='Preferred lightness scheme, either "light" or "dark".'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-a', '--app',
|
||||
required=True,
|
||||
help='Application target for theme. App must be present in the registry. ' \
|
||||
+ 'Use "*" to apply to all registered apps'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
def add_set_subparser(subparsers):
|
||||
parser = subparsers.add_parser(
|
||||
'set',
|
||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||
+ 'format).'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--palette',
|
||||
required=True,
|
||||
help='Palette name, must match a folder in themes/'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-s', '--scheme',
|
||||
required=True,
|
||||
help='Preferred lightness scheme, either "light" or "dark".'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-a', '--app',
|
||||
required=True,
|
||||
help='Application target for theme. App must be present in the registry. ' \
|
||||
+ 'Use "*" to apply to all registered apps'
|
||||
)
|
||||
parser.set_defaults(func=update_theme_settings)
|
||||
|
||||
|
||||
def get_running_path():
|
||||
|
52
pyproject.toml
Normal file
52
pyproject.toml
Normal 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
|
@ -1,3 +0,0 @@
|
||||
sphinx
|
||||
furo
|
||||
myst-parser
|
Loading…
Reference in New Issue
Block a user