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
|
.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
|
return Path(calling_module.__file__).parent
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
def add_gen_subparser(subparsers):
|
||||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
parser = subparsers.add_parser(
|
||||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
'gen',
|
||||||
+ 'format).'
|
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||||
)
|
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||||
parser.add_argument(
|
+ 'format).'
|
||||||
'-a', '--app',
|
)
|
||||||
required=True,
|
parser.add_argument(
|
||||||
help='Application target for theme. Supported: ["kitty"]'
|
'-a', '--app',
|
||||||
)
|
required=True,
|
||||||
parser.add_argument(
|
help='Application target for theme. Supported: ["kitty"]'
|
||||||
'-p', '--palette',
|
)
|
||||||
required=True,
|
parser.add_argument(
|
||||||
help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".'
|
'-p', '--palette',
|
||||||
)
|
required=True,
|
||||||
parser.add_argument(
|
help='Palette to use for template mappings. Uses local "theme/<palette>/colors.json".'
|
||||||
'-t', '--template',
|
)
|
||||||
default=None,
|
parser.add_argument(
|
||||||
help='Path to TOML template file. If omitted, app\'s default template path is used.' \
|
'-t', '--template',
|
||||||
+ 'If a directory is provided, all TOML files in the folder will be used.'
|
default=None,
|
||||||
)
|
help='Path to TOML template file. If omitted, app\'s default template path is used.' \
|
||||||
parser.add_argument(
|
+ 'If a directory is provided, all TOML files in the folder will be used.'
|
||||||
'-o', '--output',
|
)
|
||||||
default=None,
|
parser.add_argument(
|
||||||
help='Output file path for theme. If omitted, app\'s default theme output path is used.'
|
'-o', '--output',
|
||||||
)
|
default=None,
|
||||||
args = parser.parse_args()
|
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
|
# 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()
|
|
||||||
|
@ -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(
|
||||||
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
'set',
|
||||||
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
description='Generate theme files for various applications. Uses a template (in TOML ' \
|
||||||
+ 'format).'
|
+ 'format) to map application-specific config keywords to colors (in JSON ' \
|
||||||
)
|
+ 'format).'
|
||||||
parser.add_argument(
|
)
|
||||||
'-p', '--palette',
|
parser.add_argument(
|
||||||
required=True,
|
'-p', '--palette',
|
||||||
help='Palette name, must match a folder in themes/'
|
required=True,
|
||||||
)
|
help='Palette name, must match a folder in themes/'
|
||||||
parser.add_argument(
|
)
|
||||||
'-s', '--scheme',
|
parser.add_argument(
|
||||||
required=True,
|
'-s', '--scheme',
|
||||||
help='Preferred lightness scheme, either "light" or "dark".'
|
required=True,
|
||||||
)
|
help='Preferred lightness scheme, either "light" or "dark".'
|
||||||
parser.add_argument(
|
)
|
||||||
'-a', '--app',
|
parser.add_argument(
|
||||||
required=True,
|
'-a', '--app',
|
||||||
help='Application target for theme. App must be present in the registry. ' \
|
required=True,
|
||||||
+ 'Use "*" to apply to all registered apps'
|
help='Application target for theme. App must be present in the registry. ' \
|
||||||
)
|
+ '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
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