code: def tmppath(path=None, include_unix_username=True):
      
      addon = "luigitemp-%08d" % random.randrange(1e9)
      temp_dir = '/tmp'  # default tmp dir if none is specified in config
  
      # 1. Figure out to which temporary directory to place
      configured_hdfs_tmp_dir = hdfs().tmp_dir
      if configured_hdfs_tmp_dir is not None:
          # config is superior
          base_dir = configured_hdfs_tmp_dir
      elif path is not None:
          # need to copy correct schema and network location
          parsed = urlparse(path)
          base_dir = urlunparse((parsed.scheme, parsed.netloc, temp_dir, '', '', ''))
      else:
          # just system temporary directory
          base_dir = temp_dir
  
      # 2. Figure out what to place
      if path is not None:
          if path.startswith(temp_dir + '/'):
              # Not 100%, but some protection from directories like /tmp/tmp/file
              subdir = path[len(temp_dir):]
          else:
              # Protection from /tmp/hdfs:/dir/file
              parsed = urlparse(path)
              subdir = parsed.path
          subdir = subdir.lstrip('/') + '-'
      else:
          # just return any random temporary location
          subdir = ''
  
      if include_unix_username:
          subdir = os.path.join(getpass.getuser(), subdir)
  
      return os.path.join(base_dir, subdir + addon)
docs: @param path: target path for which it is needed to generate temporary location
      @type path: str
      @type include_unix_username: bool
      @rtype: str
  
      Note that include_unix_username might work on windows too.