def get_proc_dir(cachedir, **kwargs):
 fn_ = os.path.join(cachedir, 'proc')
 mode = kwargs.pop('mode', None)
 if (mode is None):
  mode = {}
 else:
  mode = {'mode': mode}
 if (not os.path.isdir(fn_)):
  os.makedirs(fn_, **mode)
 d_stat = os.stat(fn_)
 if mode:
  mode_part = S_IMODE(d_stat.st_mode)
  if (mode_part != mode['mode']):
   os.chmod(fn_, ((d_stat.st_mode ^ mode_part) | mode['mode']))
 if hasattr(os, 'chown'):
  uid = kwargs.pop('uid', (-1))
  gid = kwargs.pop('gid', (-1))
  if (((d_stat.st_uid != uid) or (d_stat.st_gid != gid)) and [i for i in (uid, gid) if (i != (-1))]):
   os.chown(fn_, uid, gid)
 return fn_

def get_proc_dir ( cachedir , ** kwargs ) : fn_ = os . path . join ( cachedir , 'proc' ) mode = kwargs . pop ( 'mode' , None ) if ( mode is None ) : mode = { } else : mode = { 'mode' : mode } if ( not os . path . isdir ( fn_ ) ) : os . makedirs ( fn_ , ** mode ) d_stat = os . stat ( fn_ ) if mode : mode_part = S_IMODE ( d_stat . st_mode ) if ( mode_part != mode [ 'mode' ] ) : os . chmod ( fn_ , ( ( d_stat . st_mode ^ mode_part ) | mode [ 'mode' ] ) ) if hasattr ( os , 'chown' ) : uid = kwargs . pop ( 'uid' , ( - 1 ) ) gid = kwargs . pop ( 'gid' , ( - 1 ) ) if ( ( ( d_stat . st_uid != uid ) or ( d_stat . st_gid != gid ) ) and [ i for i in ( uid , gid ) if ( i != ( - 1 ) ) ] ) : os . chown ( fn_ , uid , gid ) return fn_
given the cache directory .