def validate_database_path(database):
 p = os.path.abspath(database)
 if (not os.path.exists(p)):
  raise ValueError('No such file or directory')
 if os.path.isfile(p):
  p = os.path.dirname(p)
 if (not os.path.isdir(p)):
  raise ValueError('Not a directory')
 return p

def validate_database_path ( database ) : p = os . path . abspath ( database ) if ( not os . path . exists ( p ) ) : raise ValueError ( 'No such file or directory' ) if os . path . isfile ( p ) : p = os . path . dirname ( p ) if ( not os . path . isdir ( p ) ) : raise ValueError ( 'Not a directory' ) return p
returns a valid database path throws valueerrors .