~rachidbm/ubuntu-translations-stats/database-settings

« back to all changes in this revision

Viewing changes to stats/management/commands/importdata.py

  • Committer: David Planella
  • Date: 2012-02-25 10:14:50 UTC
  • Revision ID: david.planella@ubuntu.com-20120225101450-4q0w4n8ur0ur4ckq
Reverted the Language model to not having the translators count for now. Added some more documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
254
254
        return blacklist
255
255
 
256
256
    def get_default_packages(self, release):
 
257
        '''Return a list of source packages that are in a default Ubuntu
 
258
        desktop installation, from which we'll be able to determine which
 
259
        translation templates are part of the desktop installation
 
260
        
 
261
        '''
257
262
        distro_seeds =\
258
263
            distropackages.DistroPackageSet('ubuntu', release.name, True)
259
264
        distro_seeds.fetch()
287
292
 
288
293
    @transaction.commit_manually
289
294
    def add_releases(self, lp):
 
295
        '''Add Ubuntu releases to the database if they are not present, and
 
296
        update their 'active' status'''
290
297
        releases = UbuntuRelease.objects.all()
291
298
        lp_releases = launchpad.get_releases(lp)
292
299
 
317
324
        data_path = self.download_data(COUNTRIES_URL)
318
325
 
319
326
    def download_data(self, source):
 
327
        '''Downloads a data file from the given source and returns the 
 
328
        destination path'''
320
329
        tempdir = tempfile.mkdtemp()
321
330
        atexit.register(shutil.rmtree, tempdir)
322
331
 
329
338
        return destination
330
339
 
331
340
    def handle_noargs(self, **options):
 
341
        '''Fetch all data from different sources and import it into the
 
342
        database'''
332
343
        lp = launchpad.get_launchpad()
333
344
        self.add_releases(lp)
334
345
        self.add_languages(lp)