Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/databases/install.py
6915 views
1
"""
2
Automated database installation.
3
4
This file defines a command "database_install":
5
-- takes name of db as argument
6
-- if db sitting in SAGE_ROOT, installs it
7
-- if not, downloads it with wget from modular
8
and installs it.
9
"""
10
11
12
from sage.misc.misc import SAGE_DATA
13
14
class GenericDatabaseInstaller:
15
def __init__(self, name):
16
self._name = name
17
18
def __repr__(self):
19
return "Database installer for database %s"%self._name
20
21
def name(self):
22
return self._name
23
24
def directory(self):
25
"""
26
Returns the directory that contains this database.
27
"""
28
return "%s/%s"%(SAGE_DATA, self._name)
29
30
def archive_filename(self):
31
"""
32
Returns the filename of the database archive.
33
"""
34
return 'db-%s.tar'%self._name
35
36
def get_archive_file(self):
37
"""
38
Makes sure that the archive file is in the SAGE_ROOT
39
directory.
40
"""
41
filename = self.archive_filename()
42
43
def install(self):
44
F = self.archive_filename()
45
raise NotImplementedError
46
47
48
49
def database_install(name):
50
"""
51
Install the database name.
52
53
INPUT:
54
name -- string
55
OUTPUT:
56
installs the database so it is available to Sage.
57
(You may have to restart Sage.)
58
"""
59
i = name.find('.')
60
if i != -1:
61
name = name[:i]
62
print "Truncating database name to '%s'"%name
63
D = GenericDatabaseInstaller(name)
64
D.install()
65
66
67
68
69