fix missing property decorators

This commit is contained in:
Maximilian Keßler 2022-02-08 23:34:18 +01:00
parent 7318c9380d
commit 5f8411d907
5 changed files with 40 additions and 4 deletions

View file

@ -40,7 +40,7 @@ class PyTeXSourceFile:
self._file_hash = md5(self._relative_path.path)
@property
def relative_path(self):
def relative_path(self) -> RelativePath:
return self._relative_path
@property

View file

@ -0,0 +1,34 @@
from pathlib import Path
from typing import Optional, Union, List, Tuple
from .enums import PyTeXRootDirType
from .pytex_config import PyTeXConfig
from ...logger import logger
from .constants import *
from ..versioning.version_info.version_info import VersionInfo, FileVersionInfo
from .pytex_file import PyTeXSourceFile
from .relative_path import RelativePath
from .hashing import md5
class PyTeXOutputFile:
def __init__(
self,
source_file: PyTeXSourceFile,
output_file: RelativePath,
last_version_info: FileVersionInfo
):
self.output_file: RelativePath = output_file
self.source_file: PyTeXSourceFile = source_file
self.last_version_info: FileVersionInfo = last_version_info
@property
def dependencies(self) -> List[str]:
return self.source_file.formatter.dependencies
def is_recent(self) -> bool:
return self.last_version_info.file_hash == self.source_file.file_hash
@property
def file_hash(self) -> str:
return md5(self.output_file.path)

View file

@ -22,6 +22,7 @@ class DictFormatter(PyTeXFormatter):
self._dict_name = self.input_file.name.split('.')[0]
self._translations = None
@property
def dependencies(self) -> List[str]:
return [] # No dependencies for dictionaries

View file

@ -102,9 +102,9 @@ class PyTeXFormatter(FormatterIF, ABC):
or self.config.include_repo_version
or self.config.include_repo_info_text
):
self._header = GenericText([])
self._header = GenericText()
else:
self._header = GenericText([])
self._header = GenericText()
# TODO: handle license
if self.config.include_extra_header:
self._header += self.config.extra_header + ['']

View file

@ -10,7 +10,7 @@ class SimpleTeXFormatter(TexFormatter):
if out_file.exists():
raise NotImplementedError
else:
self._output_file = out_file.open()
self._output_file = out_file.open('w')
def close_output_stream(self):
self._output_file.close()
@ -18,6 +18,7 @@ class SimpleTeXFormatter(TexFormatter):
def future_config(self) -> List[Tuple[str, FormattingConfig]]:
return [] # TODO
@property
def dependencies(self) -> List[str]:
return [] # sty / cls file does not depend on anything