-
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
threejs: access files through features, for simpler configuration
- Loading branch information
Showing
5 changed files
with
81 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
|
||
from . import StaticFile | ||
|
||
|
||
class Threejs(StaticFile): | ||
r""" | ||
A :class:`~sage.features.Feature` which describes the presence of | ||
threejs-sage in a few standard locations. | ||
EXAMPLES:: | ||
sage: from sage.features.threejs import Threejs | ||
sage: bool(Threejs().is_present()) # needs threejs | ||
True | ||
""" | ||
|
||
def __init__(self): | ||
r""" | ||
TESTS:: | ||
sage: from sage.features.threejs import Threejs | ||
sage: isinstance(Threejs(), Threejs) | ||
True | ||
""" | ||
from sage.env import SAGE_SHARE, THREEJS_DIR | ||
|
||
version = self.required_version() | ||
|
||
threejs_search_path = THREEJS_DIR or ( | ||
os.path.join(SAGE_SHARE, "jupyter", "nbextensions", "threejs-sage"), | ||
os.path.join(SAGE_SHARE, "sagemath", "threejs-sage"), | ||
os.path.join(SAGE_SHARE, "sage", "threejs"), | ||
os.path.join(SAGE_SHARE, "threejs-sage") | ||
) | ||
|
||
StaticFile.__init__( | ||
self, name="threejs", | ||
filename=os.path.join(version, "three.min.js"), | ||
spkg="threejs", | ||
type="standard", | ||
search_path=threejs_search_path, | ||
description="JavaScript library to display 3D graphics") | ||
|
||
def required_version(self): | ||
""" | ||
Return the version of threejs that Sage requires. | ||
EXAMPLES:: | ||
sage: from sage.features.threejs import Threejs | ||
sage: Threejs().required_version() | ||
'r...' | ||
""" | ||
from sage.env import SAGE_EXTCODE | ||
|
||
filename = os.path.join(SAGE_EXTCODE, 'threejs', 'threejs-version.txt') | ||
|
||
with open(filename) as f: | ||
return f.read().strip() | ||
|
||
|
||
def all_features(): | ||
return [Threejs()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters