From 813a5be1be6483b92292135c1e999a8263d1b9d4 Mon Sep 17 00:00:00 2001 From: Agathe Porte Date: Sun, 14 Jun 2020 08:43:05 +0200 Subject: total revamp --- __init__.py | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to '__init__.py') diff --git a/__init__.py b/__init__.py index 80b09f4..8f28cef 100644 --- a/__init__.py +++ b/__init__.py @@ -1,35 +1,3 @@ -import subprocess +from .git_describe import register -from pelican import signals - - -class GitDescribe: - def __init__(self, gen): - self.settings = gen.settings - self.process() - - def process(self): - """Initialization process.""" - pass - - def defer_process(self): - """Check and return git describe value.""" - result = subprocess.run(["git", "describe", "--tags"], - stdout=subprocess.PIPE, check=True) - return result.stdout.decode('utf-8').strip() - - -def initialize(gen): - """Function called upon article generator initialization.""" - gen.plugin_instance = GitDescribe(gen) - - -def fetch(gen, metadata): - """Function called upon article generation context fetching.""" - gen.context['git_describe'] = gen.plugin_instance.defer_process() - - -def register(): - """Register Pelican signals to dedicated functions.""" - signals.article_generator_init.connect(initialize) - signals.article_generator_context.connect(fetch) +__all__ = ['register'] -- cgit v1.2.3