def resolve_parent(p):
 try:
  st = os.lstat(p)
 except OSError:
  st = None
 if (st and stat.S_ISLNK(st.st_mode)):
  (dir, name) = os.path.split(p)
  dir = os.path.realpath(dir)
  out = os.path.join(dir, name)
 else:
  out = os.path.realpath(p)
 return out

def resolve_parent ( p ) : try : st = os . lstat ( p ) except OSError : st = None if ( st and stat . S_ISLNK ( st . st_mode ) ) : ( dir , name ) = os . path . split ( p ) dir = os . path . realpath ( dir ) out = os . path . join ( dir , name ) else : out = os . path . realpath ( p ) return out
return the absolute path of a file without following any final symlink .