Skip to content

Commit

Permalink
✨ Reduce the overall repo size.
Browse files Browse the repository at this point in the history
Move templates to the blastpipe repo.
Make blastpipe a dependency.

Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed Apr 28, 2024
1 parent 344e354 commit cfd1234
Show file tree
Hide file tree
Showing 204 changed files with 13 additions and 9,935 deletions.
110 changes: 0 additions & 110 deletions ozi/filter.py

This file was deleted.

5 changes: 3 additions & 2 deletions ozi/fix/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from pathlib import Path
from typing import NoReturn

from ozi.filter import underscorify
from blastpipe.ozi_templates import load_environment
from blastpipe.ozi_templates.filter import underscorify

from ozi.fix.missing import report
from ozi.fix.parser import parser
from ozi.fix.rewrite_command import Rewriter
from ozi.render import load_environment
from ozi.spec import METADATA
from ozi.tap import TAP

Expand Down
3 changes: 2 additions & 1 deletion ozi/fix/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
elif sys.version_info < (3, 11): # pragma: no cover
import tomli as toml

from ozi.filter import underscorify
from blastpipe.ozi_templates.filter import underscorify

from ozi.fix.build_definition import walk
from ozi.meson import load_ast
from ozi.meson import project_metadata
Expand Down
2 changes: 0 additions & 2 deletions ozi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ source_files = [
'__main__.py',
'actions.py',
'comment.py',
'filter.py',
'meson.py',
'pkg_extra.py',
'py.typed',
Expand All @@ -29,7 +28,6 @@ source_children = [
'new',
'scripts',
'spec',
'templates',
'test',
'vendor',
]
Expand Down
6 changes: 3 additions & 3 deletions ozi/new/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from pathlib import Path
from typing import TYPE_CHECKING

from ozi.spec import METADATA

if TYPE_CHECKING:
from argparse import Namespace
from typing import Callable
Expand All @@ -22,6 +20,8 @@

Composable: TypeAlias = Callable[[Namespace], Namespace]

from blastpipe.ozi_templates import load_environment

from ozi.new.parser import parser
from ozi.new.validate import valid_contact_info
from ozi.new.validate import valid_copyright_head
Expand All @@ -32,9 +32,9 @@
from ozi.new.validate import valid_project_url
from ozi.new.validate import valid_spdx
from ozi.new.validate import valid_summary
from ozi.render import load_environment
from ozi.render import render_ci_files_set_user
from ozi.render import render_project_files
from ozi.spec import METADATA
from ozi.tap import TAP


Expand Down
55 changes: 2 additions & 53 deletions ozi/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,18 @@
# See LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Rendering utilities for the OZI project templates."""
from functools import _lru_cache_wrapper
from pathlib import Path
from types import FunctionType
from typing import Any
from warnings import warn

from blastpipe.ozi_templates.filter import underscorify
from git import InvalidGitRepositoryError
from git import Repo
from jinja2 import Environment
from jinja2 import PackageLoader
from jinja2 import TemplateNotFound
from jinja2 import select_autoescape

from ozi.filter import current_date
from ozi.filter import next_minor
from ozi.filter import sha256sum
from ozi.filter import to_distribution
from ozi.filter import underscorify
from ozi.filter import wheel_repr

from ozi.spec import METADATA
from ozi.tap import TAP

FILTERS = (
next_minor,
to_distribution,
underscorify,
zip,
sha256sum,
wheel_repr,
current_date,
)


def _init_environment(_globals: dict[str, Any]) -> Environment:
"""Initialize the rendering environment, set filters, and set global metadata."""
env = Environment(
loader=PackageLoader('ozi'),
autoescape=select_autoescape(),
enable_async=True,
auto_reload=False,
)
for f in FILTERS:
match f:
case type():
env.filters.setdefault(f.__name__, f)
case FunctionType():
env.filters.setdefault(f.__name__, f)
case _lru_cache_wrapper(): # pragma: defer to pyright,mypy
env.filters.setdefault(f.__wrapped__.__name__, f)
env.globals = env.globals | _globals
return env


def load_environment(project: dict[str, str], _globals: dict[str, Any]) -> Environment:
"""Load the rendering environment for templates.
:return: jinja2 rendering environment for OZI
:rtype: Environment
"""
env = _init_environment(_globals)
env.globals = env.globals | {'project': project}
return env


def find_user_template(target: str, file: str, fix: str) -> str | None:
"""Find a user-defined project template file e.g. :file:`{target}/templates/{fix}/{file}`.
Expand Down
31 changes: 0 additions & 31 deletions ozi/templates/.gitignore.j2

This file was deleted.

11 changes: 0 additions & 11 deletions ozi/templates/CHANGELOG.md.j2

This file was deleted.

10 changes: 0 additions & 10 deletions ozi/templates/LICENSE.txt.j2

This file was deleted.

7 changes: 0 additions & 7 deletions ozi/templates/PKG-INFO.j2

This file was deleted.

23 changes: 0 additions & 23 deletions ozi/templates/README.rst.j2

This file was deleted.

15 changes: 0 additions & 15 deletions ozi/templates/bandit.meson.options

This file was deleted.

16 changes: 0 additions & 16 deletions ozi/templates/bandit.pyproject.toml

This file was deleted.

18 changes: 0 additions & 18 deletions ozi/templates/black.meson.options

This file was deleted.

Loading

0 comments on commit cfd1234

Please sign in to comment.