doku2git: Modify `Change` to be an ABC

Engineering aside, this further reduces warnings from PyCharm.
This commit is contained in:
Danny Robson 2019-07-07 14:44:09 +10:00
parent e0092a365b
commit 2534979044
1 changed files with 22 additions and 2 deletions

View File

@ -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.