METADATA.pb: Filename is set canonically?
177471
def com_google_fonts_check_metadata_canonical_filename(font_metadata,
                                                       canonical_filename,
                                                       is_variable_font):
  """"""

  if is_variable_font:
    valid_varfont_suffixes = [
      ("Roman-VF", "Regular"),
      ("Italic-VF", "Italic"),
    ]
    for valid_suffix, style in valid_varfont_suffixes:
      if style in canonical_filename:
        canonical_filename = valid_suffix.join(canonical_filename.split(style))

  if canonical_filename != font_metadata.filename:
    yield FAIL, ("METADATA.pb: filename field (\"{}\")"
                 " does not match "
                 "canonical name \"{}\".".format(font_metadata.filename,
                                                 canonical_filename))
  else:
    yield PASS, "Filename in METADATA.pb is set canonically."
36982
def default(thumbnailer, prepared_options, source_filename,
            thumbnail_extension, **kwargs):
    
    filename_parts = [source_filename]
    if ('%(opts)s' in thumbnailer.thumbnail_basedir or
            '%(opts)s' in thumbnailer.thumbnail_subdir):
        if thumbnail_extension != os.path.splitext(source_filename)[1][1:]:
            filename_parts.append(thumbnail_extension)
    else:
        filename_parts += ['_'.join(prepared_options), thumbnail_extension]
    return '.'.join(filename_parts)
558099
def _modname(path):
    """"""
    base = os.path.basename(path)
    filename, ext = os.path.splitext(base)
    return filename
594088
def set_metadata(self, metadata):
        
        if metadata is not None:
            metadata = np.array(metadata, copy=False).ravel()
        self.metadata = metadata
1125055
def save_local_metadata(self):
        
        # save to the set local path and add .json
        with open(self.filepath + '.json', 'w+') as outfile:
            json.dump(self._prep_metadata(), outfile, indent=4)
349599
def archive_basename(filename):
    ''''''
    for archive in archive_formats:
        if filename.endswith(archive_formats[archive]['suffix']):
            return filename.rstrip('.' + archive_formats[archive]['suffix'])
    return False
984146
public void setFileName() {
        String type = "";
        // lenskit does not provide a factorizer class. This check is to actually see if it's a Mahout or Lenskit SVD.
        if (properties.containsKey(RecommendationRunner.FACTORIZER) || properties.containsKey(RecommendationRunner.SIMILARITY)) {
            if (properties.containsKey(RecommendationRunner.FACTORIZER)) {
                type = properties.getProperty(RecommendationRunner.FACTORIZER);
            } else {
                type = properties.getProperty(RecommendationRunner.SIMILARITY);
            }
            type = type.substring(type.lastIndexOf(".") + 1) + ".";
        }
        String num = "";
        if (properties.containsKey(RecommendationRunner.FACTORS) || properties.containsKey(RecommendationRunner.NEIGHBORHOOD)) {
            if (properties.containsKey(RecommendationRunner.FACTORS)) {
                num = properties.getProperty(RecommendationRunner.FACTORS);
            } else {
                num = properties.getProperty(RecommendationRunner.NEIGHBORHOOD);
            }
            num += ".";
        }

        String trainingSet = properties.getProperty(RecommendationRunner.TRAINING_SET);
        trainingSet = trainingSet.substring(trainingSet.lastIndexOf("/") + 1, trainingSet.lastIndexOf("_train"));

        fileName = trainingSet + "."
                + properties.getProperty(RecommendationRunner.FRAMEWORK) + "."
                + properties.getProperty(RecommendationRunner.RECOMMENDER).substring(properties.getProperty(RecommendationRunner.RECOMMENDER).lastIndexOf(".") + 1) + "."
                + type
                + num
                + "tsv";

        System.out.println(fileName);
    }
1288162
def generate_fileattr_metadata(local_path, metadata):
    # type: (blobxfer.models.upload.LocalPath, dict) -> dict
    
    if blobxfer.util.on_windows():
        global _FILEATTR_WARNED_ON_WINDOWS
        if not _FILEATTR_WARNED_ON_WINDOWS:
            _FILEATTR_WARNED_ON_WINDOWS = True
            logger.warning(
                'file attributes store/restore on Windows is not '
                'supported yet')
        return None
    else:
        md = {
            _JSON_KEY_FILE_ATTRIBUTES: {
                _JSON_KEY_FILE_ATTRIBUTES_POSIX: {
                    _JSON_KEY_FILE_ATTRIBUTES_MODE: local_path.mode,
                    _JSON_KEY_FILE_ATTRIBUTES_UID: local_path.uid,
                    _JSON_KEY_FILE_ATTRIBUTES_GID: local_path.gid,
                }
            }
        }
        return blobxfer.util.merge_dict(metadata, md)
963493
def set_metadata(track, filename, album=None):
    
    logger.info('Setting tags...')
    global arguments
    artwork_url = track['artwork_url']
    user = track['user']
    if not artwork_url:
        artwork_url = user['avatar_url']
    artwork_url = artwork_url.replace('large', 't500x500')
    response = requests.get(artwork_url, stream=True)
    with tempfile.NamedTemporaryFile() as out_file:
        shutil.copyfileobj(response.raw, out_file)
        out_file.seek(0)

        track_created = track['created_at']
        track_date = datetime.strptime(track_created, "%Y/%m/%d %H:%M:%S %z")
        debug_extract_dates = '{0} {1}'.format(track_created, track_date)
        logger.debug('Extracting date: {0}'.format(debug_extract_dates))
        track['date'] = track_date.strftime("%Y-%m-%d %H::%M::%S")

        track['artist'] = user['username']
        if arguments['--extract-artist']:
            for dash in [' - ', ' − ', ' – ', ' — ', ' ― ']:
                if dash in track['title']:
                    artist_title = track['title'].split(dash)
                    track['artist'] = artist_title[0].strip()
                    track['title'] = artist_title[1].strip()
                    break

        audio = mutagen.File(filename, easy=True)
        audio['title'] = track['title']
        audio['artist'] = track['artist']
        if album: audio['album'] = album
        if track['genre']: audio['genre'] = track['genre']
        if track['permalink_url']: audio['website'] = track['permalink_url']
        if track['date']: audio['date'] = track['date']
        audio.save()

        a = mutagen.File(filename)
        if track['description']:
            if a.__class__ == mutagen.flac.FLAC:
                a['description'] = track['description']
            elif a.__class__ == mutagen.mp3.MP3:
                a['COMM'] = mutagen.id3.COMM(
                    encoding=3, lang=u'ENG', text=track['description']
                )
        if artwork_url:
            if a.__class__ == mutagen.flac.FLAC:
                p = mutagen.flac.Picture()
                p.data = out_file.read()
                p.width = 500
                p.height = 500
                p.type = mutagen.id3.PictureType.COVER_FRONT
                a.add_picture(p)
            elif a.__class__ == mutagen.mp3.MP3:
                a['APIC'] = mutagen.id3.APIC(
                    encoding=3, mime='image/jpeg', type=3,
                    desc='Cover', data=out_file.read()
                )
        a.save()
791192
def file_name
      name = ""
      name += @user.nickname
      name += "-"
      name += @organization.name.parameterize
      name += "-"
      name += token
      name + ".zip"
    end
1139544
def avoid_name_collisions(filehandle, meta):
    
    if meta.get('avoid_name_collision', True):
        filename = filehandle.filename
        original, ext = os.path.splitext(filehandle.filename)
        counter = count()
        while os.path.exists(get_save_path(filename)):
            fixer = str(next(counter))
            filename = '{}_{}{}'.format(original, fixer, ext)
        filehandle.filename = filename
    return filehandle
411442
def full_original_filename
      parent_name = super
      extension = File.extname(parent_name)
      base_name = parent_name.chomp(extension)
      base_name = base_name[version_name.size.succ..-1] if version_name
      [base_name, version_name].compact.join('-') + extension
    end
275976
def suggest_filename(metadata):
	

	if 'title' in metadata and 'track_number' in metadata:  # Music Manager.
		suggested_filename = f"{metadata['track_number']:0>2} {metadata['title']}"
	elif 'title' in metadata and 'trackNumber' in metadata:  # Mobile.
		suggested_filename = f"{metadata['trackNumber']:0>2} {metadata['title']}"
	elif 'title' in metadata and 'tracknumber' in metadata:  # audio-metadata/mutagen.
		track_number = _split_number_field(
			list_to_single_value(
				metadata['tracknumber']
			)
		)
		title = list_to_single_value(metadata['title'])

		suggested_filename = f"{track_number:0>2} {title}"
	else:
		suggested_filename = f"00 {list_to_single_value(metadata.get('title', ['']))}"

	return _replace_invalid_characters(suggested_filename)
60203
def cookbook_name(file)
      raise ArgumentError, "File cannot be nil or empty" if file.to_s.empty?

      # Name is a special case as we want to fallback to the cookbook directory
      # name if metadata_field fails
      begin
        metadata_field(file, "name")
      rescue RuntimeError
        until (file.split(File::SEPARATOR) & standard_cookbook_subdirs).empty?
          file = File.absolute_path(File.dirname(file.to_s))
        end
        file = File.dirname(file) unless File.extname(file).empty?
        File.basename(file)
      end
    end
906967
def pkg_data_filename(resource_name, filename=None):
    
    resource_filename = pkg_resources.resource_filename(
        tripleohelper.__name__,
        resource_name
    )
    if filename is not None:
        resource_filename = os.path.join(resource_filename, filename)
    return resource_filename
206158
def filenameToModname(self, filename):
        """"""
        for ext in reversed(self._exts):
            if filename.endswith(ext):
                filename = filename[:-len(ext)]
                break
        else:
            self.warn(filename, '%s: unknown file name extension', filename)
        filename = os.path.abspath(filename)
        elements = filename.split(os.path.sep)
        modname = []
        while elements:
            modname.append(elements[-1])
            del elements[-1]
            if not os.path.exists(os.path.sep.join(elements + ['__init__.py'])):
                break
        modname.reverse()
        modname = ".".join(modname)
        return modname
1107505
def copy_metadata_to(self, target_dir):
        ""
        # normalize the path (so that a forward-slash in egg_info will
        # match using startswith below)
        norm_egg_info = os.path.normpath(self.egg_info)
        prefix = os.path.join(norm_egg_info, '')
        for path in self.ei_cmd.filelist.files:
            if path.startswith(prefix):
                target = os.path.join(target_dir, path[len(prefix):])
                ensure_directory(target)
                self.copy_file(path, target)