#################################################################################1#2# (c) Copyright 2010 William Stein3#4# This file is part of PSAGE5#6# PSAGE is free software: you can redistribute it and/or modify7# it under the terms of the GNU General Public License as published by8# the Free Software Foundation, either version 3 of the License, or9# (at your option) any later version.10#11# PSAGE is distributed in the hope that it will be useful,12# but WITHOUT ANY WARRANTY; without even the implied warranty of13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14# GNU General Public License for more details.15#16# You should have received a copy of the GNU General Public License17# along with this program. If not, see <http://www.gnu.org/licenses/>.18#19#################################################################################202122"""23This module implements an object that is used to coordinate populating24the database.2526This is an abstract base class for other classes, e.g., for populating27the database with newforms.28"""2930class Populate:31def __init__(self, collection):32self.collection = collection3334def percent_done(self):35return 100*float(self.count()) / self.collection.count()3637def populate_all(self, verbose=True):38while True:39if self.count() == self.collection.count():40break41d = self.percent_done()42if verbose: print "Percent done: %.2f%%"%d43self.populate_one(verbose=verbose)44454647