def get_valid_cwd():
 try:
  cwd = (os.getenv('PWD') or os.getcwd())
 except:
  warn((('Your current directory is invalid. If you open a ticket at ' + 'https://github.com/milkbikis/powerline-shell/issues/new ') + 'we would love to help fix the issue.'))
  sys.stdout.write('> ')
  sys.exit(1)
 parts = cwd.split(os.sep)
 up = cwd
 while (parts and (not os.path.exists(up))):
  parts.pop()
  up = os.sep.join(parts)
 if (cwd != up):
  warn(('Your current directory is invalid. Lowest valid directory: ' + up))
 return cwd

def get_valid_cwd ( ) : try : cwd = ( os . getenv ( 'PWD' ) or os . getcwd ( ) ) except : warn ( ( ( 'Your current directory is invalid. If you open a ticket at ' + 'https://github.com/milkbikis/powerline-shell/issues/new ' ) + 'we would love to help fix the issue.' ) ) sys . stdout . write ( '> ' ) sys . exit ( 1 ) parts = cwd . split ( os . sep ) up = cwd while ( parts and ( not os . path . exists ( up ) ) ) : parts . pop ( ) up = os . sep . join ( parts ) if ( cwd != up ) : warn ( ( 'Your current directory is invalid. Lowest valid directory: ' + up ) ) return cwd
we check if the current working directory is valid or not .