Return a unique file name.
964258
def _get_filename(self):
        """"""
        if self._fname is None:
            timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
            fname = "%s-%s.log" % (timestamp, abs(id(self)))
            self._fname = os.path.join(self.file_path, fname)
        return self._fname
721398
def file_signature(filename):
    

    if not os.path.isfile(filename):
        return None
    if not os.path.exists(filename):
        return None

    # Duplicate auto-generated files can be recognized with the sha1 hash.
    sig = hashlib.sha1()
    with open(filename, "rb") as f:
        buf = f.read()
        sig.update(buf)

    return sig.hexdigest()
1145497
public function getUniqFileName($dir, $name, $sep = '-')
    {
        list($name, $ext) = $this->standardizeFileName($name, true);

        $nameF = $name.'.'.$ext;
        $i = 2;
        while (isset($this->uniqFileNames[$dir.'/'.$nameF]) || file_exists($dir.'/'.$nameF)) {
            $nameF = $name.$sep.$i.'.'.$ext;
            ++$i;
        }
        $this->uniqFileNames[$dir.'/'.$nameF] = true;

        return $nameF;
    }
686772
def generate_filename(self, instance, filename):
        
        from unidecode import unidecode

        return super().generate_filename(instance, unidecode(force_text(filename)))
1081854
def __getFilenameSuffix(self, filename):
        """"""
        if filename and isinstance(filename, string_types):
            if self.__isValidTGZ(filename):
                return ".tar.gz"
            elif filename.endswith(".zip"):
                return ".zip"
1343956
def file_id_to_name(self, file_id):
        """"""
        sql = 'select name from files where id = ?'
        logging.debug('%s %s', sql, (file_id,))
        self.cursor.execute(sql, (file_id,))
        name = self.cursor.fetchone()
        if name:
            return name[0]
        return ''
930486
def filename(self, prefix='', suffix='', extension='.py'):
        """"""
        return BASE_NAME.format(prefix, self.num, suffix, extension)
260475
def check_duplicate_filenames(files):
    """"""
    # Check whether we'll have duplicates
    used_names = set()
    dup_names = list()

    for this_file in files:
        this_fname = os.path.basename(this_file)
        if this_fname in used_names:
            dup_names.append(this_file)
        else:
            used_names.add(this_fname)

    if len(dup_names) > 0:
        logger.warning(
            'Duplicate file name(s) found. Having duplicate file names will '
            'break some links. List of files: {}'.format(sorted(dup_names),))
1099375
def acquire_filename(self, name):
        

        id_ = self.__id_lut.get(name)
        # Is this a new entry?
        if id_ is None:
            # then create one...
            id_ = self.__next_id
            self.__next_id += 1
            self.__id_lut[name] = id_
            entry = filename_entry_t(name)
            self.__entries[id_] = entry
        else:
            # otherwise obtain the entry...
            entry = self.__entries[id_]

        entry.inc_ref_count()
        return id_, self._get_signature(entry)
1022334
private String filename(final File aFile) {
		try {
			return aFile.getCanonicalPath();
		} catch (IOException ex) {
			recordException(ex);
			return "UNKNOWN FILE";
		}
	}
177741
def unique(self, name):
    """"""
    # Make sure the name is valid
    name = self.valid(name)
    # Make sure it's not too long
    name = self.trim(name)
    # Now make sure it's unique
    unique_name = name
    i = 2
    while unique_name in self.names:
      unique_name = name + str(i)
      i += 1
    self.names.add(unique_name)
    return unique_name
40917
public function uniqueFilename($data)
	{
		$filename = $this->automaticFilename($data);

		if (file_exists($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
		{
			$ext = strrchr($filename, '.');
			$prefix = substr($filename, 0, -strlen($ext));

			$i = 1;

			while (is_file($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
			{
				$filename = $prefix . ++$i . $ext;
			}
		}

		$data['filename'] = $filename;

		return $data['filename'];
	}
1027773
def get_unique_name(name='', collection=()):
    '''
    
    '''
    if name not in collection:
        return name
    i = 1
    while True:
        i += 1
        name2 = '%s_%s' % (name, i)
        if name2 not in collection:
            return name2
288207
def create_unique_autosave_filename(self, filename, autosave_dir):
        
        basename = osp.basename(filename)
        autosave_filename = osp.join(autosave_dir, basename)
        if autosave_filename in self.name_mapping.values():
            counter = 0
            root, ext = osp.splitext(basename)
            while autosave_filename in self.name_mapping.values():
                counter += 1
                autosave_basename = '{}-{}{}'.format(root, counter, ext)
                autosave_filename = osp.join(autosave_dir, autosave_basename)
        return autosave_filename
177792
def ExistingFileOrNone(fname):
    """"""
    if os.path.isfile(fname):
        return fname
    elif fname.lower() == 'none':
        return None
    else:
        raise ValueError("%s must specify a valid file name or 'None'" % fname)
1186451
def frame_unique(f):
        
        return f.f_code.co_filename, f.f_code.co_name, f.f_lineno
412641
public function getUniqueFilename($filename)
    {
        $uniqueName = uniqid();
        $fileExt    = explode('.', $filename);
        $mimeType   = end($fileExt);
        $filename   = $uniqueName . '.' . $mimeType;

        return $filename;
    }