INNER CODE UNIT · Python

checkifoutfileexists

idnahacks/GoodHound · goodhound/ghutils.py:23

def checkifoutfileexists(file):
        while Path(file).exists():
            stem = Path(file).stem
            newfile = str(Path(file).with_stem(stem + '-' + (datetime.now()).strftime("%Y-%m-%d-%H-%M")))
            file = newfile
        return file

def checkoutdir(path):
    """Check if the user input output path exists and is a directory and creates the file path if needed."""
    if Path(path).exists():
        if not Path(path).is_dir():
            logging.error('Selected output path is not a directory')
            exit(1)
    else:
        os.makedirs(path, exist_ok=True)

def checkdbfileexists(sqlpath):
    """Looks at the provided sql-path argument and determines whether to create a new db or update an existing one."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…