From 25349790440d9d36668950f1a393a2b93d428287 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 7 Jul 2019 14:44:09 +1000 Subject: [PATCH] doku2git: Modify `Change` to be an ABC Engineering aside, this further reduces warnings from PyCharm. --- doku2git.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/doku2git.py b/doku2git.py index c091109..32e34fb 100755 --- a/doku2git.py +++ b/doku2git.py @@ -5,6 +5,7 @@ from typing import List, Dict, Iterable, Callable, Generator from operator import attrgetter +import abc import os.path import os import collections @@ -57,7 +58,7 @@ class User(object): # ----------------------------------------------------------------------------- -class Change(object): +class Change(abc.ABC): """ The base class for all change records in the Dokuwiki instance. @@ -88,6 +89,25 @@ class Change(object): def __str__(self): return f'{self.user}@{self.timestamp}:{self.page} "{self.description}"' + @abc.abstractmethod + def _update(self, _src, _dst: str) -> Generator[str, None, None]: + """ + Yield the commands required to unpack this change. + :param _src: The Dokuwiki instance this change belongs to. + :param _dst: The absolute path to the root of the git repository + :return: + """ + pass + + @abc.abstractmethod + def _attic(self, _src) -> str: + """ + Find the path to the history data within the Dokuwiki directories. + :param _src: The Dokuwiki instance this change belongs to. + :return: The relative path from the root of Dokuwiki to the data. + """ + pass + def _delete(self, _src: str, _dst: str) -> Generator[str, None, None]: """ Generates the required commands to delete a given page @@ -243,7 +263,7 @@ class MediaChange(Change): f'{basename}.{self.timestamp}{extension}' ) - def _update(self, src: str, dst: str) -> Generator[str, None, None]: + def _update(self, src, dst: str) -> Generator[str, None, None]: """ Yields the commands required to unpack this one change. :param src: The Dokuwiki instance this change belongs to.