Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
34282: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
soehms committed Aug 5, 2022
1 parent cd1e2b1 commit c599e49
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions src/sage/features/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# ****************************************************************************

from . import StaticFile, Executable, FeatureTestResult, FeatureNotPresentError
from sage.features.join_feature import JoinFeature

latex_url = 'https://www.latex-project.org/'

class latex(Executable):
r"""
Expand All @@ -32,8 +35,7 @@ def __init__(self):
sage: isinstance(latex(), latex)
True
"""
Executable.__init__(self, "latex", executable="latex",
url="https://www.latex-project.org/")
Executable.__init__(self, "latex", executable="latex", url=latex_url)

def is_functional(self):
r"""
Expand Down Expand Up @@ -92,8 +94,7 @@ def __init__(self):
sage: isinstance(pdflatex(), pdflatex)
True
"""
Executable.__init__(self, "pdflatex", executable="pdflatex",
url="https://www.latex-project.org/")
Executable.__init__(self, "pdflatex", executable="pdflatex", url=latex_url)

class xelatex(Executable):
r"""
Expand All @@ -113,8 +114,8 @@ def __init__(self):
sage: isinstance(xelatex(), xelatex)
True
"""
Executable.__init__(self, "xelatex", executable="xelatex",
url="https://www.latex-project.org/")
Executable.__init__(self, "xelatex", executable="xelatex", url=latex_url)


class lualatex(Executable):
r"""
Expand All @@ -134,11 +135,10 @@ def __init__(self):
sage: isinstance(lualatex(), lualatex)
True
"""
Executable.__init__(self, "lualatex", executable="lualatex",
url="https://www.latex-project.org/")
Executable.__init__(self, "lualatex", executable="lualatex", url=latex_url)


class TeXFile(StaticFile):
class TeXFile(StaticFile, JoinFeature):
r"""
A :class:`sage.features.Feature` describing the presence of a TeX file
Expand All @@ -151,6 +151,14 @@ class TeXFile(StaticFile):
FeatureTestResult('nonexisting', False)
"""
def __init__(self, name, filename, **kwds):
r"""
EXAMPLES::
sage: from sage.features.latex import LaTeXPackage, pdflatex
sage: LaTeXPackage("tkz-graph")._features
[Feature('pdflatex')]
"""
JoinFeature.__init__(self, name, [pdflatex()], url=latex_url) # see :trac:`34282`
StaticFile.__init__(self, name, filename, search_path=[], **kwds)

def absolute_filename(self) -> str:
Expand All @@ -174,6 +182,22 @@ def absolute_filename(self) -> str:
raise FeatureNotPresentError(self,
reason="{filename!r} not found by kpsewhich".format(filename=self.filename))

def _is_present(self):
r"""
Test for the presence of the TeX-file.
EXAMPLES::
sage: from sage.features.latex import LaTeXPackage, pdflatex
sage: f = LaTeXPackage("tkz-graph")
sage: g = pdflatex()
sage: bool(f.is_present()) == bool(g.is_present()) # indirect doctest
True
"""
test = JoinFeature._is_present(self)
if not test:
return test
return super(TeXFile, self)._is_present()

class LaTeXPackage(TeXFile):
r"""
Expand Down

0 comments on commit c599e49

Please sign in to comment.