diff --git a/.gitignore b/.gitignore index 98d3626..2511f64 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..93f98c5 --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..68d1aeb --- /dev/null +++ b/TODO.md @@ -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 diff --git a/autoconf/__init__.py b/autoconf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/autoconf/__main__.py b/autoconf/__main__.py new file mode 100644 index 0000000..4fc1567 --- /dev/null +++ b/autoconf/__main__.py @@ -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() diff --git a/autoconf/gen_theme.py b/autoconf/gen_theme.py index dac99e0..12bd8fc 100644 --- a/autoconf/gen_theme.py +++ b/autoconf/gen_theme.py @@ -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//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//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() diff --git a/autoconf/set_theme.py b/autoconf/set_theme.py index 27400d8..c077924 100644 --- a/autoconf/set_theme.py +++ b/autoconf/set_theme.py @@ -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(): diff --git a/autoconf/app_registry.toml b/config/app_registry.toml similarity index 100% rename from autoconf/app_registry.toml rename to config/app_registry.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..780bb05 --- /dev/null +++ b/pyproject.toml @@ -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 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 600e05f..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -sphinx -furo -myst-parser