How to use the picard.formats.open_ function in picard

To help you get started, we’ve selected a few picard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metabrainz / picard / test / formats / common.py View on Github external
def save_metadata(filename, metadata):
    f = picard.formats.open_(filename)
    loaded_metadata = f._load(filename)
    f._copy_loaded_metadata(loaded_metadata)
    f._save(filename, metadata)
github metabrainz / picard / test / formats / coverart.py View on Github external
def test_cover_art_with_types(self):
            expected = set('abcdefg'[:]) if self.supports_types else set('a')
            f = picard.formats.open_(self.filename)
            f._save(self.filename, self._cover_metadata())

            f = picard.formats.open_(self.filename)
            loaded_metadata = f._load(self.filename)
            found = set([chr(img.data[-1]) for img in loaded_metadata.images])
            self.assertEqual(expected, found)
github metabrainz / picard / test / test_formats.py View on Github external
def save_metadata(filename, metadata):
    f = picard.formats.open_(filename)
    f._save(filename, metadata)
github metabrainz / picard / test / test_filesystem.py View on Github external
def _move_additional_files(self, files):
        f = picard.formats.open_(files['old_mp3'])
        f._move_additional_files(files['old_mp3'], files['new_mp3'])

        self._assertFile(files['new_img'])
        self._assertNoFile(files['old_img'])
github metabrainz / picard / test / test_formats.py View on Github external
def _test_cover_art_types(self, filename, expect):
        self._set_up(filename)
        expect = {ord(char) for char in expect}
        try:
            f = picard.formats.open_(self.filename)
            f._save(self.filename, self._cover_metadata())

            f = picard.formats.open_(self.filename)
            loaded_metadata = f._load(self.filename)
            found = set()
            for n, image in enumerate(loaded_metadata.images):
                found.add(image.data[-1])
            self.assertEqual(expect, found)
        finally:
            self._tear_down()
github metabrainz / picard / test / formats / test_coverart.py View on Github external
def _test_cover_art_types_only_front(self, filename, expect):
        self._set_up(filename, {'embed_only_one_front_image': True})
        expect = {ord(char) for char in expect}
        try:
            f = picard.formats.open_(self.filename)
            f._save(self.filename, self._cover_metadata())

            f = picard.formats.open_(self.filename)
            loaded_metadata = f._load(self.filename)
            found = set()
            for n, image in enumerate(loaded_metadata.images):
                found.add(image.data[-1])
            self.assertEqual(expect, found)
        finally:
            self._tear_down()
github metabrainz / picard / test / formats / common.py View on Github external
def test_split_ext(self):
            f = picard.formats.open_(self.filename)
            self.assertEqual(f._fixed_splitext(f.filename), os.path.splitext(f.filename))
            self.assertEqual(f._fixed_splitext(f.EXTENSIONS[0]), ('', f.EXTENSIONS[0]))
            self.assertEqual(f._fixed_splitext('.test'), os.path.splitext('.test'))
            self.assertNotEqual(f._fixed_splitext(f.EXTENSIONS[0]), os.path.splitext(f.EXTENSIONS[0]))
github metabrainz / picard / test / formats / common.py View on Github external
def test_guess_format(self):
            temp_file = self.copy_of_original_testfile()
            audio = picard.formats.guess_format(temp_file)
            audio_original = picard.formats.open_(self.filename)
            self.assertEqual(type(audio), type(audio_original))
github metabrainz / picard / test / formats / test_coverart.py View on Github external
def _test_cover_art(self, filename):
        self._set_up(filename)
        try:
            source_types = ["front", "booklet"]
            # Use reasonable large data > 64kb.
            # This checks a mutagen error with ASF files.
            tests = [
                CoverArtImage(data=self.jpegdata + b"a" * 1024 * 128, types=source_types),
                CoverArtImage(data=self.pngdata + b"a" * 1024 * 128, types=source_types),
            ]
            for test in tests:
                self._file_save_image(self.filename, test)
                f = picard.formats.open_(self.filename)
                loaded_metadata = f._load(self.filename)
                image = loaded_metadata.images[0]
                self.assertEqual(test.mimetype, image.mimetype)
                self.assertEqual(test, image)
        finally:
            self._tear_down()