gnarly 0.0.0.dev2__tar.gz → 0.0.0.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gnarly might be problematic. Click here for more details.
- gnarly-0.0.0.dev5/PKG-INFO +15 -0
- gnarly-0.0.0.dev5/docs/Makefile +20 -0
- gnarly-0.0.0.dev5/docs/make.bat +35 -0
- gnarly-0.0.0.dev5/docs/source/api.md +29 -0
- gnarly-0.0.0.dev5/docs/source/conf.py +79 -0
- gnarly-0.0.0.dev5/docs/source/index.md +15 -0
- gnarly-0.0.0.dev5/docs/source/usage.md +11 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/pyproject.toml +10 -14
- gnarly-0.0.0.dev5/src/gnarly/__init__.py +53 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/src/gnarly/constants.py +8 -3
- gnarly-0.0.0.dev5/src/gnarly/errors.py +29 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/__init__.py +44 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/code/__init__.py +33 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/code/projects.py +205 -0
- {gnarly-0.0.0.dev2/src/gnarly/utilities → gnarly-0.0.0.dev5/src/gnarly/utils}/io.py +50 -39
- gnarly-0.0.0.dev5/src/gnarly/utils/llm/__init__.py +22 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/llm/chatgpt.py +94 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/llm/claude.py +99 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/llm/interfaces.py +237 -0
- gnarly-0.0.0.dev5/src/gnarly/utils/llm/models.py +195 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/tests/test_io_utilities.py +1 -1
- gnarly-0.0.0.dev5/uv.lock +1135 -0
- gnarly-0.0.0.dev2/PKG-INFO +0 -8
- gnarly-0.0.0.dev2/src/gnarly/__init__.py +0 -22
- gnarly-0.0.0.dev2/src/gnarly/utilities/__init__.py +0 -18
- gnarly-0.0.0.dev2/uv.lock +0 -594
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/.gitignore +0 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/.python-version +0 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/README.md +0 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/tests/__init__.py +0 -0
- {gnarly-0.0.0.dev2 → gnarly-0.0.0.dev5}/tests/test_constants.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gnarly
|
|
3
|
+
Version: 0.0.0.dev5
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author-email: "K. LeBryce" <k.lebryce@pm.me>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: anthropic>=0.54.0
|
|
8
|
+
Requires-Dist: linkify>=1.4
|
|
9
|
+
Requires-Dist: myst-parser>=4.0.1
|
|
10
|
+
Requires-Dist: openai>=1.86.0
|
|
11
|
+
Requires-Dist: pytest>=8.4.0
|
|
12
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
13
|
+
Requires-Dist: sphinx-autobuild>=2024.10.3
|
|
14
|
+
Requires-Dist: sphinx>=8.1.3
|
|
15
|
+
Requires-Dist: starch
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Core Module
|
|
4
|
+
|
|
5
|
+
```{eval-rst}
|
|
6
|
+
.. automodule:: gnarly
|
|
7
|
+
:members:
|
|
8
|
+
:undoc-members:
|
|
9
|
+
:show-inheritance:
|
|
10
|
+
|
|
11
|
+
.. automodule:: gnarly.constants
|
|
12
|
+
:members:
|
|
13
|
+
:undoc-members:
|
|
14
|
+
:show-inheritance:
|
|
15
|
+
|
|
16
|
+
.. automodule:: gnarly.errors
|
|
17
|
+
:members:
|
|
18
|
+
:undoc-members:
|
|
19
|
+
:show-inheritance:
|
|
20
|
+
|
|
21
|
+
.. automodule:: gnarly.utils.io
|
|
22
|
+
:members:
|
|
23
|
+
:undoc-members:
|
|
24
|
+
:show-inheritance:
|
|
25
|
+
|
|
26
|
+
.. automodule:: gnarly.utils.code.projects
|
|
27
|
+
:members:
|
|
28
|
+
:undoc-members:
|
|
29
|
+
:show-inheritance:
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
# Add your source code to the path so Sphinx can find your modules
|
|
10
|
+
sys.path.insert(0, os.path.abspath('../../src'))
|
|
11
|
+
|
|
12
|
+
# -- Project information -----------------------------------------------------
|
|
13
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
14
|
+
|
|
15
|
+
project = 'gnarly'
|
|
16
|
+
copyright = '2025, K. LeBryce'
|
|
17
|
+
author = 'K. LeBryce'
|
|
18
|
+
release = '0.0.0'
|
|
19
|
+
|
|
20
|
+
# -- General configuration ---------------------------------------------------
|
|
21
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
22
|
+
|
|
23
|
+
extensions = [
|
|
24
|
+
'sphinx.ext.autodoc', # Automatically generate docs from docstrings
|
|
25
|
+
'sphinx.ext.viewcode', # Add [source] links to documentation
|
|
26
|
+
'sphinx.ext.napoleon', # Support for Google and NumPy style docstrings
|
|
27
|
+
'sphinx.ext.intersphinx', # Link to other project's documentation
|
|
28
|
+
'myst_parser', # MyST Markdown parser
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
# MyST parser configuration
|
|
32
|
+
myst_enable_extensions = [
|
|
33
|
+
"colon_fence", # ::: fenced code blocks
|
|
34
|
+
"deflist", # Definition lists
|
|
35
|
+
"html_admonition", # HTML-style admonitions
|
|
36
|
+
"html_image", # HTML images with attributes
|
|
37
|
+
"replacements", # Text replacements like (c) -> ©
|
|
38
|
+
"smartquotes", # Smart quotes
|
|
39
|
+
"substitution", # Variable substitutions
|
|
40
|
+
"tasklist", # GitHub-style task lists
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
# Templates path
|
|
44
|
+
templates_path = ['_templates']
|
|
45
|
+
|
|
46
|
+
# Files to exclude from processing
|
|
47
|
+
exclude_patterns = []
|
|
48
|
+
|
|
49
|
+
# Source file suffixes and their parsers
|
|
50
|
+
source_suffix = {
|
|
51
|
+
'.rst': 'restructuredtext',
|
|
52
|
+
'.md': 'markdown',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# -- Options for HTML output -------------------------------------------------
|
|
56
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
57
|
+
|
|
58
|
+
html_theme = 'sphinx_rtd_theme'
|
|
59
|
+
html_static_path = ['_static']
|
|
60
|
+
|
|
61
|
+
# -- Extension configuration -------------------------------------------------
|
|
62
|
+
|
|
63
|
+
# Autodoc configuration
|
|
64
|
+
autodoc_default_options = {
|
|
65
|
+
'members': True,
|
|
66
|
+
'undoc-members': True,
|
|
67
|
+
'show-inheritance': True,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Napoleon configuration (for Google/NumPy style docstrings)
|
|
71
|
+
napoleon_google_docstring = True
|
|
72
|
+
napoleon_numpy_docstring = True
|
|
73
|
+
napoleon_include_init_with_doc = False
|
|
74
|
+
napoleon_include_private_with_doc = False
|
|
75
|
+
|
|
76
|
+
# Intersphinx mapping (links to other documentation)
|
|
77
|
+
intersphinx_mapping = {
|
|
78
|
+
'python': ('https://docs.python.org/3', None),
|
|
79
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "gnarly"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.0dev5"
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -8,8 +8,15 @@ authors = [
|
|
|
8
8
|
]
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
dependencies = [
|
|
11
|
+
"anthropic>=0.54.0",
|
|
12
|
+
"linkify>=1.4",
|
|
13
|
+
"myst-parser>=4.0.1",
|
|
14
|
+
"openai>=1.86.0",
|
|
11
15
|
"pytest>=8.4.0",
|
|
12
16
|
"python-dotenv>=1.1.0",
|
|
17
|
+
"sphinx>=8.1.3",
|
|
18
|
+
"sphinx-autobuild>=2024.10.3",
|
|
19
|
+
"starch",
|
|
13
20
|
]
|
|
14
21
|
|
|
15
22
|
[project.scripts]
|
|
@@ -19,16 +26,5 @@ gnarly = "gnarly:main"
|
|
|
19
26
|
requires = ["hatchling"]
|
|
20
27
|
build-backend = "hatchling.build"
|
|
21
28
|
|
|
22
|
-
[
|
|
23
|
-
|
|
24
|
-
"mypy>=1.16.0",
|
|
25
|
-
"pytest>=8.4.0",
|
|
26
|
-
"ruff>=0.11.13",
|
|
27
|
-
"starch>=0.0.0.dev8",
|
|
28
|
-
]
|
|
29
|
-
extras = [
|
|
30
|
-
"ipython>=8.37.0",
|
|
31
|
-
]
|
|
32
|
-
optional = [
|
|
33
|
-
"requests>=2.32.4",
|
|
34
|
-
]
|
|
29
|
+
[tool.uv.sources]
|
|
30
|
+
starch = { path = "../starch" }
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gnarly
|
|
3
|
+
======
|
|
4
|
+
|
|
5
|
+
A general-use abstraction layer for the lazy.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
from . import errors, constants, utils
|
|
11
|
+
from .errors import NamespaceError
|
|
12
|
+
from .utils import code, io, llm
|
|
13
|
+
from .utils.code.projects import (
|
|
14
|
+
GnarlyProject,
|
|
15
|
+
GnarlyCppProject,
|
|
16
|
+
GnarlyHaskellProject,
|
|
17
|
+
GnarlyJavaScriptProject,
|
|
18
|
+
GnarlyPythonProject,
|
|
19
|
+
GnarlyRProject,
|
|
20
|
+
GnarlyRustProject,
|
|
21
|
+
GnarlySwiftProject,
|
|
22
|
+
GnarlyProjectType,
|
|
23
|
+
Project
|
|
24
|
+
)
|
|
25
|
+
from .utils.io import stream
|
|
26
|
+
from .utils.llm import claude, chatgpt, ChatGPT, Claude
|
|
27
|
+
|
|
28
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
29
|
+
logger = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
import starch
|
|
33
|
+
__all__ = ["starch"]
|
|
34
|
+
except ImportError as e:
|
|
35
|
+
logger.error(f"Could not import `starch`: {e}")
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
# ─── package-level exports ───────────────────────────────────────────────
|
|
39
|
+
"code", "llm", "utils",
|
|
40
|
+
|
|
41
|
+
# ─── module-level exports ────────────────────────────────────────────────
|
|
42
|
+
"chatgpt", "claude", "errors", "constants", "io",
|
|
43
|
+
|
|
44
|
+
# ─── function-level exports ──────────────────────────────────────────────
|
|
45
|
+
"stream",
|
|
46
|
+
|
|
47
|
+
# ─── class-level exports ─────────────────────────────────────────────────
|
|
48
|
+
"ChatGPT", "Claude",
|
|
49
|
+
"GnarlyProject", "GnarlyCppProject", "GnarlyHaskellProject",
|
|
50
|
+
"GnarlyJavaScriptProject", "GnarlyPythonProject", "GnarlyRustProject",
|
|
51
|
+
"GnarlyRProject", "GnarlyRustProject", "GnarlySwiftProject",
|
|
52
|
+
"GnarlyProjectType", "NamespaceError", "Project"
|
|
53
|
+
]
|
|
@@ -22,9 +22,10 @@ logger.setLevel(logging.DEBUG)
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
# ─── package metadata ─────────────────────────────────────────────────── ✦✦ ─
|
|
25
|
-
__author__ = "K. LeBryce <kosmolebryce@gmail.com>"
|
|
26
|
-
__package__ = "Gnarly"
|
|
27
|
-
__version__ = "0.0.0"
|
|
25
|
+
__author__: str = "K. LeBryce <kosmolebryce@gmail.com>"
|
|
26
|
+
__package__: str = "Gnarly"
|
|
27
|
+
__version__: str = "0.0.0"
|
|
28
|
+
__description__: str = "A sophisticated abstraction layer for lazy developers."
|
|
28
29
|
|
|
29
30
|
# ─── resource references ──────────────────────────────────────────────── ✦✦ ─
|
|
30
31
|
GNARLY_DATA_DIR: Path = user_data_path(
|
|
@@ -55,6 +56,9 @@ GNARLY_LOG_DIR: Path = user_log_path(
|
|
|
55
56
|
ensure_exists=True
|
|
56
57
|
)
|
|
57
58
|
|
|
59
|
+
GNARLY_PROJECT_ROOT_PATH: Path = Path.home() / "gnarly/"
|
|
60
|
+
GNARLY_PROJECT_ROOT_PATH.mkdir(exist_ok=True)
|
|
61
|
+
|
|
58
62
|
DOTENV_FILE_PATH: Path = GNARLY_CONFIG_DIR / "gnarly.env"
|
|
59
63
|
DOTENV_FILE_PATH.touch()
|
|
60
64
|
|
|
@@ -75,3 +79,4 @@ except IOError as e:
|
|
|
75
79
|
f"{GNARLY_CONFIG_DIR.resolve()}"
|
|
76
80
|
)
|
|
77
81
|
raise RuntimeError from e
|
|
82
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Errors
|
|
3
|
+
======
|
|
4
|
+
|
|
5
|
+
This module defines the custom exception types used throughout the
|
|
6
|
+
code base. This is a Gnarly implementation detail.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
from .constants import GNARLY_LOG_DIR
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
logging.basicConfig(
|
|
15
|
+
level=logging.DEBUG,
|
|
16
|
+
filename=(GNARLY_LOG_DIR / "gnarly.log").resolve()
|
|
17
|
+
)
|
|
18
|
+
logger.info("Logger setup complete.")
|
|
19
|
+
|
|
20
|
+
class GnarlyError(Exception):
|
|
21
|
+
"""Gnarly's base error class."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NamespaceError(GnarlyError):
|
|
26
|
+
"""
|
|
27
|
+
An error type that arises from an improper namespace access attempt.
|
|
28
|
+
"""
|
|
29
|
+
pass
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utilities
|
|
3
|
+
=========
|
|
4
|
+
|
|
5
|
+
A convenient library comprising a collection of simple Python utilities.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
from . import code, io, llm
|
|
9
|
+
from .code import (
|
|
10
|
+
GnarlyProject,
|
|
11
|
+
GnarlyCppProject,
|
|
12
|
+
GnarlyHaskellProject,
|
|
13
|
+
GnarlyJavaScriptProject,
|
|
14
|
+
GnarlyPythonProject,
|
|
15
|
+
GnarlyRProject,
|
|
16
|
+
GnarlyRustProject,
|
|
17
|
+
GnarlySwiftProject,
|
|
18
|
+
GnarlyProjectType,
|
|
19
|
+
Project
|
|
20
|
+
)
|
|
21
|
+
from .llm.interfaces import ChatGPT, Claude
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
# ─── package-level exports ───────────────────────────────────────────────
|
|
26
|
+
"code", "llm",
|
|
27
|
+
|
|
28
|
+
# ─── module-level exports ────────────────────────────────────────────────
|
|
29
|
+
"io",
|
|
30
|
+
|
|
31
|
+
# ─── class-level exports ─────────────────────────────────────────────────
|
|
32
|
+
"ChatGPT",
|
|
33
|
+
"Claude",
|
|
34
|
+
"GnarlyProject",
|
|
35
|
+
"GnarlyCppProject",
|
|
36
|
+
"GnarlyHaskellProject",
|
|
37
|
+
"GnarlyJavaScriptProject",
|
|
38
|
+
"GnarlyPythonProject",
|
|
39
|
+
"GnarlyRProject",
|
|
40
|
+
"GnarlyRustProject",
|
|
41
|
+
"GnarlySwiftProject",
|
|
42
|
+
"GnarlyProjectType",
|
|
43
|
+
"Project"
|
|
44
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gnarly Code
|
|
3
|
+
|
|
4
|
+
Developer utilities.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from . projects import (
|
|
9
|
+
GnarlyProject,
|
|
10
|
+
GnarlyCppProject,
|
|
11
|
+
GnarlyHaskellProject,
|
|
12
|
+
GnarlyJavaScriptProject,
|
|
13
|
+
GnarlyPythonProject,
|
|
14
|
+
GnarlyRProject,
|
|
15
|
+
GnarlyRustProject,
|
|
16
|
+
GnarlySwiftProject,
|
|
17
|
+
GnarlyProjectType,
|
|
18
|
+
Project
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"GnarlyProject",
|
|
24
|
+
"GnarlyCppProject",
|
|
25
|
+
"GnarlyHaskellProject",
|
|
26
|
+
"GnarlyJavaScriptProject",
|
|
27
|
+
"GnarlyPythonProject",
|
|
28
|
+
"GnarlyRProject",
|
|
29
|
+
"GnarlyRustProject",
|
|
30
|
+
"GnarlySwiftProject",
|
|
31
|
+
"GnarlyProjectType",
|
|
32
|
+
"Project"
|
|
33
|
+
]
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Projects
|
|
3
|
+
========
|
|
4
|
+
|
|
5
|
+
This module defines and implements various facilities useful for
|
|
6
|
+
project management.
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from enum import Enum, auto
|
|
11
|
+
import logging
|
|
12
|
+
from os import PathLike
|
|
13
|
+
|
|
14
|
+
from ...constants import GNARLY_PROJECT_ROOT_PATH
|
|
15
|
+
from ...errors import NamespaceError
|
|
16
|
+
|
|
17
|
+
logger: logging.Logger = logging.getLogger()
|
|
18
|
+
logging.basicConfig(level=logging.DEBUG, format=logging.BASIC_FORMAT)
|
|
19
|
+
|
|
20
|
+
class GnarlyProjectType(Enum):
|
|
21
|
+
"""
|
|
22
|
+
An enumeration of currently supported languages.
|
|
23
|
+
|
|
24
|
+
Reference members of this class directly whenever you want to specify
|
|
25
|
+
a language constraint. Avoid hard-coding comparisons to their `values`,
|
|
26
|
+
since their integer data types are semantically insignificant.
|
|
27
|
+
"""
|
|
28
|
+
CPP: int = auto()
|
|
29
|
+
HASKELL: int = auto()
|
|
30
|
+
JAVASCRIPT: int = auto()
|
|
31
|
+
PYTHON: int = auto()
|
|
32
|
+
R: int = auto()
|
|
33
|
+
RUST: int = auto()
|
|
34
|
+
SWIFT: int = auto()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Project:
|
|
38
|
+
"""
|
|
39
|
+
A namespace for Gnarly Code's project management utility suite.
|
|
40
|
+
|
|
41
|
+
This is a Gnarly implementation detail. It is not intended for direct
|
|
42
|
+
instantiation. Attempts to instantiate this class will raise a
|
|
43
|
+
`NamespaceError`.
|
|
44
|
+
"""
|
|
45
|
+
def __new__(cls) -> None:
|
|
46
|
+
logger.error("`Project` is not intended for direct instantiation.")
|
|
47
|
+
raise NamespaceError(
|
|
48
|
+
f"Canot instantiate namespace class {cls.__name__}"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# ─── Utility Groups ──────────────────────────────────────────────────────
|
|
52
|
+
class Python:
|
|
53
|
+
"""
|
|
54
|
+
A namespace for Gnarly's Python project management utilities.
|
|
55
|
+
|
|
56
|
+
Use the static functions defined in the `Project.Python` namespace to
|
|
57
|
+
manage your Python project's code base.
|
|
58
|
+
|
|
59
|
+
Examples
|
|
60
|
+
--------
|
|
61
|
+
Basic usage:
|
|
62
|
+
|
|
63
|
+
>>> from gnarly.utils.code import Project
|
|
64
|
+
>>> p = Project.Python # Alias for convenience.
|
|
65
|
+
>>> p.create("my_project")
|
|
66
|
+
GnarlyPythonProject(
|
|
67
|
+
name="my_project",
|
|
68
|
+
project_type=GnarlyProjectType.PYTHON,
|
|
69
|
+
logger=None,
|
|
70
|
+
is_persistent=True,
|
|
71
|
+
root_path=Path(
|
|
72
|
+
"/users/gnarly-user/gnarly/projects/python/my_project/"
|
|
73
|
+
),
|
|
74
|
+
dependencies={"dev": [], "optional": [], "required": []}
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
With custom options:
|
|
78
|
+
|
|
79
|
+
>>> from gnarly.utils.code import Project
|
|
80
|
+
>>> p = Project.Python
|
|
81
|
+
>>> p.create(
|
|
82
|
+
... name="My Project",
|
|
83
|
+
... project_type=
|
|
84
|
+
... )
|
|
85
|
+
GnarlyPythonProject(
|
|
86
|
+
name="my_project",
|
|
87
|
+
project_type=GnarlyProjectType.PYTHON,
|
|
88
|
+
logger=None,
|
|
89
|
+
is_persistent=True,
|
|
90
|
+
root_path=Path(
|
|
91
|
+
"/users/gnarly-user/gnarly/projects/python/my_project/"
|
|
92
|
+
),
|
|
93
|
+
dependencies={"dev": [], "optional": [], "required": []}
|
|
94
|
+
)
|
|
95
|
+
"""
|
|
96
|
+
def create(
|
|
97
|
+
cls,
|
|
98
|
+
logger: logging.Logger = logging.getLogger(__name__),
|
|
99
|
+
name: str = __package__,
|
|
100
|
+
project_type = GnarlyProjectType.PYTHON,
|
|
101
|
+
is_persistent: bool = True,
|
|
102
|
+
root_path: PathLike = GNARLY_PROJECT_ROOT_PATH / f"{__package__}/",
|
|
103
|
+
dependencies: dict[str, list] = {
|
|
104
|
+
"dev": [],
|
|
105
|
+
"optional": [],
|
|
106
|
+
"required": []
|
|
107
|
+
}
|
|
108
|
+
) -> "GnarlyPythonProject":
|
|
109
|
+
return Project.create(
|
|
110
|
+
name=__package__,
|
|
111
|
+
project_type=GnarlyProjectType.PYTHON,
|
|
112
|
+
logger=(
|
|
113
|
+
logging.getLogger(__class__)
|
|
114
|
+
.basicConfig(
|
|
115
|
+
level=logging.ERROR,
|
|
116
|
+
format=logging.BASIC_FORMAT
|
|
117
|
+
)
|
|
118
|
+
),
|
|
119
|
+
is_persistent=is_persistent,
|
|
120
|
+
root_path=root_path,
|
|
121
|
+
dependencies=dependencies
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def create(
|
|
127
|
+
name: str,
|
|
128
|
+
project_type: GnarlyProjectType,
|
|
129
|
+
logger: logging.Logger = logger,
|
|
130
|
+
is_persistent: bool = True,
|
|
131
|
+
root_path: PathLike = GNARLY_PROJECT_ROOT_PATH,
|
|
132
|
+
dependencies: dict[str, list] = {
|
|
133
|
+
"dev": [],
|
|
134
|
+
"optional": [],
|
|
135
|
+
"required": []
|
|
136
|
+
}
|
|
137
|
+
) -> "GnarlyProject":
|
|
138
|
+
match project_type:
|
|
139
|
+
case project_type.HASKELL:
|
|
140
|
+
return GnarlyHaskellProject(
|
|
141
|
+
name=name,
|
|
142
|
+
project_type=project_type,
|
|
143
|
+
logger=logger,
|
|
144
|
+
is_persistent=is_persistent,
|
|
145
|
+
root_path=root_path,
|
|
146
|
+
dependencies=dependencies
|
|
147
|
+
)
|
|
148
|
+
case project_type.PYTHON:
|
|
149
|
+
return GnarlyPythonProject
|
|
150
|
+
case project_type.R:
|
|
151
|
+
return GnarlyRProject
|
|
152
|
+
case project_type.RUST:
|
|
153
|
+
return GnarlyRustProject
|
|
154
|
+
case project_type.SWIFT:
|
|
155
|
+
return GnarlySwiftProject
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@dataclass
|
|
159
|
+
class GnarlyProject:
|
|
160
|
+
name: str
|
|
161
|
+
project_type: GnarlyProjectType
|
|
162
|
+
logger: logging.Logger
|
|
163
|
+
is_persistent: bool
|
|
164
|
+
root_path: PathLike
|
|
165
|
+
dependencies: dict[str, list]
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@dataclass
|
|
169
|
+
class GnarlyPythonProject(GnarlyProject):
|
|
170
|
+
project_type = GnarlyProjectType.PYTHON
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@dataclass
|
|
174
|
+
class GnarlyCppProject(GnarlyProject):
|
|
175
|
+
project_Type = GnarlyProjectType.CPP
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@dataclass
|
|
179
|
+
class GnarlyHaskellProject(GnarlyProject):
|
|
180
|
+
project_type = GnarlyProjectType.HASKELL
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@dataclass
|
|
185
|
+
class GnarlyJavaScriptProject(GnarlyProject):
|
|
186
|
+
project_type = GnarlyProjectType.JAVASCRIPT
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@dataclass
|
|
191
|
+
class GnarlyRProject(GnarlyProject):
|
|
192
|
+
project_type = GnarlyProjectType.R
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass
|
|
196
|
+
class GnarlyRustProject(GnarlyProject):
|
|
197
|
+
project_type = GnarlyProjectType.RUST
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@dataclass
|
|
202
|
+
class GnarlySwiftProject(GnarlyProject):
|
|
203
|
+
project_type = GnarlyProjectType.SWIFT
|
|
204
|
+
pass
|
|
205
|
+
|