53022d273f6a6acd1bef8667b504a20dfc0523c8,pudl/datastore.py,,organize,#Any#Any#Any#Any#Any#Any#,230

Before Change


        // move the new file from wherever it is, to its rightful home.
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        os.rename(newfile, destfile)
    // If no_download is True, then we already did this rmtree and rename
    // The last time this program ran.

    // If we"re unzipping the downloaded file, then we may have some

After Change


    tmpdir = os.path.join(datadir, "tmp")
    // For non-CEMS, the newfiles and destfiles lists will have length 1.
    newfiles = [os.path.join(tmpdir, os.path.basename(f))
        for f in paths_for_year(source, year)]
    destfiles = paths_for_year(source, year, file=True, datadir=datadir)

    // If we"ve gotten to this point, we"re wiping out the previous version of
    // the data for this source and year... so lets wipe it! Scary!
    destdir = path(source, year, file=False, datadir=datadir)
    if not no_download:
        if os.path.exists(destdir):
            shutil.rmtree(destdir)
        // move the new file from wherever it is, to its rightful home.
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        for newfile, destfile in zip(newfiles, destfiles):
            // paranoid safety check to make sure these files match...
            assert os.path.basename(newfile) == os.path.basename(destfile)
            shutil.move(newfile, destfile)  // works more cases than os.rename
    // If no_download is True, then we already did this rmtree and move
    // The last time this program ran.

    // If we"re unzipping the downloaded file, then we may have some
    // reorganization to do. Currently all data sources will get unzipped,
    // except the CEMS, because they"re really big and take up 92% less space.
    if(unzip and source != "epacems"):
        // Unzip the downloaded file in its new home:
        zip_ref = zipfile.ZipFile(destfile, "r")
        zip_ref.extractall(destdir)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: catalyst-cooperative/pudl
Commit Name: 53022d273f6a6acd1bef8667b504a20dfc0523c8
Time: 2018-05-31
Author: karldw@users.noreply.github.com
File Name: pudl/datastore.py
Class Name:
Method Name: organize


Project Name: has2k1/plotnine
Commit Name: 3c4c60ef5dce4695ebe29f2680058310daef77b9
Time: 2015-04-20
Author: has2k1@gmail.com
File Name: ggplot/layer.py
Class Name: layer
Method Name: compute_aesthetics


Project Name: catalyst-cooperative/pudl
Commit Name: 5c0fc16071aa5ed0c459702bddc73df7e6ae7a49
Time: 2018-06-15
Author: karldw@users.noreply.github.com
File Name: pudl/datastore.py
Class Name:
Method Name: organize