Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241862 views
1
#################################################################################
2
#
3
# (c) Copyright 2010 William Stein
4
#
5
# This file is part of PSAGE
6
#
7
# PSAGE is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# PSAGE is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
#################################################################################
21
22
23
"""
24
This module implements an object that is used to coordinate populating
25
the database.
26
27
This is an abstract base class for other classes, e.g., for populating
28
the database with newforms.
29
"""
30
31
class Populate:
32
def __init__(self, collection):
33
self.collection = collection
34
35
def percent_done(self):
36
return 100*float(self.count()) / self.collection.count()
37
38
def populate_all(self, verbose=True):
39
while True:
40
if self.count() == self.collection.count():
41
break
42
d = self.percent_done()
43
if verbose: print "Percent done: %.2f%%"%d
44
self.populate_one(verbose=verbose)
45
46
47