629167ee324a0b955ef46cd5a0cd7bb504ef8c44,hyperspy/misc/io/tools.py,,ensure_directory,#Any#,77

Before Change



def ensure_directory(path):
    Check if the path exists and if it does not create the directory
    directory = os.path.split(path)[0]
    if directory and not os.path.exists(directory):
        os.makedirs(directory)


def overwrite(fname):
     If file exists "fname", ask for overwriting and return True or False,
    else return True.

After Change


    Check if the path exists and if it does not, creates the directory.
    // If it"s a file path, try the parent directory instead
    p = Path(path)
    p = p.parent if p.is_file() else p

    try:
        p.mkdir(parents=True, exist_ok=False)
    except FileExistsError:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: hyperspy/hyperspy
Commit Name: 629167ee324a0b955ef46cd5a0cd7bb504ef8c44
Time: 2020-09-09
Author: tjof2@cam.ac.uk
File Name: hyperspy/misc/io/tools.py
Class Name:
Method Name: ensure_directory


Project Name: RaRe-Technologies/gensim
Commit Name: 72613496a44888ac680811942ae865141cff89f8
Time: 2012-03-08
Author: radimrehurek@seznam.cz
File Name: gensim/models/hdpmodel.py
Class Name: HdpModel
Method Name: __init__


Project Name: PyThaiNLP/pythainlp
Commit Name: 3546a316472865828ddbc56c5019aecd7a335082
Time: 2018-06-23
Author: wannaphong@yahoo.com
File Name: pythainlp/word_vector/thai2vec.py
Class Name:
Method Name: download


Project Name: hyperspy/hyperspy
Commit Name: 629167ee324a0b955ef46cd5a0cd7bb504ef8c44
Time: 2020-09-09
Author: tjof2@cam.ac.uk
File Name: hyperspy/misc/io/tools.py
Class Name:
Method Name: ensure_directory