Abstract out release history and cleanup template globals
Committed 5bffaf
--- a/webint_code/__init__.py
+++ b/webint_code/__init__.py
subprocess.run(["gunzip", shortened], cwd=testing_dir)
+def get_package_releases(project):
+ versions = list(
+ reversed(
+ sorted(
+ app.model.get_package_versions(project),
+ key=semver.parse_version_info,
+ )
+ )
+ )
+ return [
+ (
+ version,
+ web.application("webint_posts").model.read(
+ f"code/projects/{project}/releases/{version}"
+ ),
+ )
+ for version in versions
+ ]
+
+
@app.query
def search(db, query):
"""Search for `query` in commited code."""
project,
gmpg.get_repo(project_dir / "working"),
readme,
- [
- (
- release,
- web.application("webint_posts").model.get(
- f"code/projects/{project}/releases/{release}"
- ),
- )
- for release in reversed(
- sorted(
- app.model.get_package_versions(project),
- key=semver.parse_version_info,
- )
- )
- ],
+ get_package_releases(project),
pyproject,
api_python,
test_results,
--- a/webint_code/templates/__init__.py
+++ b/webint_code/templates/__init__.py
from sys import stdlib_module_names
import emoji
-import semver
from gmpg.git import colorize_diff
from radon.metrics import mi_rank
from web import tx
"pformat",
"re",
"tx",
- "semver",
"highlight",
"stdlib_module_names",
"mi_rank",