Format identifier -> file extension
161370
def get_file_extension(format_):
    """"""
    if format_ not in FORMAT_IDENTIFIER_TO_FORMAT_CLASS:
        raise UnknownFormatIdentifierError(format_)

    for ext, f in FILE_EXTENSION_TO_FORMAT_IDENTIFIER.items():
        if f == format_:
            return ext

    raise RuntimeError("No file extension for format %r" % format_)
816050
function _getOutputFileName(path, extension) {
        var filename = path.split('/');
        filename = filename[filename.length - 1];
        filename = filename.split('.');
    
        // No extension found
        if (filename.length === 1) {
          return filename[0] + '.' + extension;
        }
    
        // Hidden file
        if (filename[0] === '') {
          filename = filename.slice(1);
          filename[0] = '.' + filename[0];
          if (filename.length === 1) {
            return filename[0] + '.' + extension;
          }
        }
    
        filename = filename.slice(0, -1);
        
        return filename + '.' + extension;
      }
1166048
def guess_format(path):
    """"""
    for fmt in formats:
        if fmt.verify(path):
            return fmt.__name__
    else:
        msg = "Undefined file format: '{}'".format(path)
        raise UnknownFileFormatError(msg)
753706
def _format_target(self, net, f, idx):
        """"""
        if f is None:
            return None
        if isinstance(f, str):
            f = self.fn_prefix + f.format(
                net=net,
                last_epoch=net.history[idx],
                last_batch=net.history[idx, 'batches', -1],
            )
            return os.path.join(self.dirname, f)
        return f
216403
def split_by_extensions(filename):
        
        parts = filename.split('.')
        idx = len(parts) - 1
        while FileFormat.is_file_format(parts[idx]):
            parts[idx] = FileFormat(parts[idx])
            idx -= 1
        return ['.'.join(parts[:idx + 1])] + parts[idx + 1:]
1013244
private String getFilePath(ExtensionId id, String fileExtension)
    {
        String encodedId = PathUtils.encode(id.getId());
        String encodedVersion = PathUtils.encode(id.getVersion().toString());
        String encodedType = PathUtils.encode(fileExtension);

        return encodedId + File.separator + encodedVersion + File.separator + encodedId + '-' + encodedVersion + '.'
            + encodedType;
    }
741435
def file_id_to_file_name(file_id):
        
        if len(file_id) == 40 and re.match("^[a-f0-9]+$", file_id):
            return file_id
        # prefix with "re_" to avoid name collision with real fileids
        return "re_{}".format(hashlib.sha1(file_id).hexdigest())
296419
def _generate_identifier_name(self, columns, prefix="", max_size=30):
        
        hash = ""
        for column in columns:
            hash += "%x" % binascii.crc32(encode(str(column)))

        return (prefix + "_" + hash)[:max_size]
775972
def get_anchor_format(a):
    

    # (. or format=) then (file_extension) then (? or $)
    # e.g. "...format=txt" or "...download.mp4?..."
    fmt = re.search(r"(?:\.|format=)(\w+)(?:\?.*)?$", a)
    return fmt.group(1) if fmt else None
1200557
function normalizeFormat(format) {
  const clone = Object.assign({}, format);
  clone.prefix = normalizePrefixSuffix(format.prefix);
  clone.suffix = normalizePrefixSuffix(format.suffix);
  return clone;
}
1332028
def extract_identifier!(args)
      options = extract_options!(args)
      identifier = normalize_set_identifier(extract_environment!(options))
      args << options
      identifier
    end
1328492
def _format_type(lines, element, spacer=""):
    """"""
    rlines = []
    rlines.append(element.signature)
    _format_summary(rlines, element)

    rlines.append("")
    _format_generic(rlines, element, ["summary"])

    if len(element.executables) > 0:
        rlines.append("\nEMBEDDED PROCEDURES")
        for key, value in list(element.executables.items()):
            rlines.append("  {}".format(value.__str__()))
            target = value.target
            if target is not None:
                _format_executable(rlines, target, "  ")

    if len(element.members) > 0:
        rlines.append("\nEMBEDDED MEMBERS")
        for key, value in list(element.members.items()):
            _format_value_element(rlines, value, "  ")

    lines.extend([spacer + l for l in rlines])
65197
def file_id(self):
        
        if self.type.lower() == "directory":
            return None
        if self.file_uuid is None:
            raise exceptions.MetsError(
                "No FILEID: File %s does not have file_uuid set" % self.path
            )
        if self.is_aip:
            return os.path.splitext(os.path.basename(self.path))[0]
        return utils.FILE_ID_PREFIX + self.file_uuid
143937
def infer_format(filename:str) -> str:
    """"""
    _, ext = os.path.splitext(filename)
    return ext
78979
def guess_format( filename, ext, formats, io_table ):
    
    ok = False
    for format in formats:
        output( 'guessing %s' % format )
        try:
            ok = io_table[format].guess( filename )
        except AttributeError:
            pass
        if ok: break

    else:
        raise NotImplementedError('cannot guess format of a *%s file!' % ext)

    return format
1332213
def _get_extension(file):
    
    if isinstance(file, str):
        return os.path.splitext(file)[-1]
    elif isinstance(file, bytes):
        kind = imghdr.what(io.BytesIO(file))
        return ('.' + kind) if kind else ''
    elif isinstance(file, io.IOBase) and file.seekable():
        kind = imghdr.what(file)
        return ('.' + kind) if kind is not None else ''
    elif getattr(file, 'name', None):
        # Note: ``file.name`` works for :tl:`InputFile` and some `IOBase`
        return _get_extension(file.name)
    else:
        return ''
382449
private String getFilename(String filename, File file) {
        if (!file.exists()) {
            file.mkdirs();
        }
        String ext = ".jpg";
        //get extension
        /*if (Pattern.matches("^[.][p][n][g]", filename)){
            ext = ".png";
        }*/

        return (file.getAbsolutePath() + "/IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ext);

    }