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

Commit

Permalink
sage.features.FileFeature: Add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Mar 4, 2022
1 parent 57531d0 commit 66b8125
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,31 @@ class FileFeature(Feature):
A subclass should implement a method :meth:`absolute_filename`.
EXAMPLES::
EXAMPLES:
Two direct concrete subclasses of :class:`FileFeature` are defined::
sage: from sage.features import StaticFile, Executable, FileFeature
sage: issubclass(StaticFile, FileFeature)
True
sage: issubclass(Executable, FileFeature)
True
To work with the file described by the feature, use the method :meth:`absolute_filename`.
A :class:`FeatureNotPresentError` is raised if the file cannot be found::
sage: Executable(name="does-not-exist", executable="does-not-exist-xxxxyxyyxyy").absolute_path()
Traceback (most recent call last):
...
sage.features.FeatureNotPresentError: does-not-exist is not available.
Executable 'does-not-exist-xxxxyxyyxyy' not found on PATH.
A :class:`FileFeature` also provides the :meth:`is_present` method to test for
the presence of the file at run time. This is inherited from the base class
:class:`Feature`::
sage: Executable(name="sh", executable="sh").is_present()
FeatureTestResult('sh', True)
"""
def _is_present(self):
r"""
Expand All @@ -455,7 +473,7 @@ def absolute_filename(self) -> str:
Concrete subclasses must override this abstract method.
EXAMPLES::
TESTS::
sage: from sage.features import FileFeature
sage: FileFeature(name="abstract_file").absolute_filename()
Expand Down

0 comments on commit 66b8125

Please sign in to comment.