def configure_build_root( srcDir, default = None ):
    root = None
    input_string = False
    _default = None

    if not default:
        _default = srcDir[:-1].join( "alembic_build" )

    while True:
        input_string = "[%s]: " % _default
        if default:
            file_path = default
        else:
            print
            print "Please enter the location where you would like to build the Alembic"
            print "system (default: %s)" % _default
            file_path = Path( raw_input( input_string ) )

        if file_path.isempty():
            file_path = Path( _default )
        else:
            file_path = file_path.toabs()

        print "Checking '%s'" % file_path

        if file_path.isdir():
            print "'%s' exists; awesome!" % file_path
            return file_path
        else:
            print "Creating '%s'" % file_path
            try:
                os.makedirs( str( file_path ) )
                root = file_path
                break
            except Exception, e:
                print "Could not create build directory '%s'; got error:" % file_path
                print e
def configure_build_root(srcDir, default=None):
    root = None
    input_string = False
    _default = None

    if not default:
        _default = srcDir[:-1].join("alembic_build")

    while True:
        input_string = "[%s]: " % _default
        if default:
            file_path = default
        else:
            print
            print "Please enter the location where you would like to build the Alembic"
            print "system (default: %s)" % _default
            file_path = Path(raw_input(input_string))

        if file_path.isempty():
            file_path = Path(_default)
        else:
            file_path = file_path.toabs()

        print "Checking '%s'" % file_path

        if file_path.isdir():
            print "'%s' exists; awesome!" % file_path
            return file_path
        else:
            print "Creating '%s'" % file_path
            try:
                os.makedirs(str(file_path))
                root = file_path
                break
            except Exception, e:
                print "Could not create build directory '%s'; got error:" % file_path
                print e
def validate_path( p, wantdir=False ):
    p = Path( p )
    if wantdir:
        return p.isdir()
    else:
        return p.exists() and not p.isdir()
def validate_path(p, wantdir=False):
    p = Path(p)
    if wantdir:
        return p.isdir()
    else:
        return p.exists() and not p.isdir()