def InterpolatePath(path, client, users=None, path_args=None, depth=0):
 sys_formatters = {'systemroot': 'c:\\Windows'}
 if path_args:
  sys_formatters.update(path_args)
 if users:
  results = []
  for user in users:
   user = GetUserInfo(client, user)
   if user:
    formatters = dict(((x.name, y) for (x, y) in user.ListSetFields()))
    formatters.update(sys_formatters)
    try:
     results.append(path.format(**formatters))
    except KeyError:
     pass
  return results
 else:
  try:
   path = path.format(**sys_formatters)
  except KeyError:
   logging.warn('Failed path interpolation on %s', path)
   return ''
  if (('{' in path) and (depth < 10)):
   path = InterpolatePath(path, client=client, users=users, path_args=path_args, depth=(depth + 1))
  return path

def InterpolatePath ( path , client , users = None , path_args = None , depth = 0 ) : sys_formatters = { 'systemroot' : 'c:\\Windows' } if path_args : sys_formatters . update ( path_args ) if users : results = [ ] for user in users : user = GetUserInfo ( client , user ) if user : formatters = dict ( ( ( x . name , y ) for ( x , y ) in user . ListSetFields ( ) ) ) formatters . update ( sys_formatters ) try : results . append ( path . format ( ** formatters ) ) except KeyError : pass return results else : try : path = path . format ( ** sys_formatters ) except KeyError : logging . warn ( 'Failed path interpolation on %s' , path ) return '' if ( ( '{' in path ) and ( depth < 10 ) ) : path = InterpolatePath ( path , client = client , users = users , path_args = path_args , depth = ( depth + 1 ) ) return path
take a string as a path on a client and interpolate with client data .