How to use the picard.log 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 / test_vorbis.py View on Github external
def test_invalid_rating(self):
            filename = os.path.join('test', 'data', 'test-invalid-rating.ogg')
            old_log_level = log.get_effective_level()
            log.set_level(logging.ERROR)
            metadata = load_metadata(filename)
            log.set_level(old_log_level)
            self.assertEqual(metadata["~rating"], "THERATING")
github metabrainz / picard / picard / file.py View on Github external
self.clear_pending()
            self._add_path_to_metadata(self.orig_metadata)
            self.metadata_images_changed.emit()

            # run post save hook
            run_file_post_save_processors(self)

        # Force update to ensure file status icon changes immediately after save
        self.update()

        if self.state != File.REMOVED:
            del self.tagger.files[old_filename]
            self.tagger.files[new_filename] = self

        if self.tagger.stopping:
            log.debug("Save of %r completed before stopping Picard", self.filename)
github metabrainz / picard-plugins / plugins / tangoinfo / tangoinfo.py View on Github external
def barcode_process_metadata(self, barcode, response):

        # Check whether we have a concealed 404 and get the homepage
        if "<title>Contents - tango.info</title>" in response:
            log.debug("%s: No album with barcode %s on tango.info",
                      PLUGIN_NAME, barcode)
            return

        table = table_regex.search(response)
        if not table:
            log.warning("%s: No table found on page for barcode %s on tango.info",
                        PLUGIN_NAME, barcode)
            return

        albuminfo = {}
        trcontent = [match.groups()[0] for match in trs.finditer(table)]

        for tr in trcontent:
            trackinfo = [trmatch.groups()[0] for trmatch in tds.finditer(tr)]
            if not trackinfo: # check if list is empty, e.g. contains a 
                continue

            # Get genre
            if trackinfo[3] and not trackinfo[3] == "-":
                genre = unicode(
                            re.split('&lt;|&gt;', trackinfo[3])[2].title(), 'utf8'
                        )
github metabrainz / picard-plugins / plugins / decode_cyrillic / decode_cyrillic.py View on Github external
def unmangle(self, tag, value):
        try:
            print(value, value.encode('latin1'))
            unmangled_value = value.encode('latin1').decode('cp1251')
        except UnicodeError:
            unmangled_value = value
            log.debug("%s: could not unmangle tag %s; original value: %s" % (PLUGIN_NAME, tag, value))
        return unmangled_value
github metabrainz / picard / picard / formats / id3.py View on Github external
def _load(self, filename):
        log.debug("Loading file %r", filename)
        file = self._File(encode_filename(filename), ID3=compatid3.CompatID3)
        tags = file.tags or {}
        # upgrade custom 2.3 frames to 2.4
        for old, new in self.__upgrade.items():
            if old in tags and new not in tags:
                f = tags.pop(old)
                tags.add(getattr(id3, new)(encoding=f.encoding, text=f.text))
        metadata = Metadata()
        for frame in tags.values():
            frameid = frame.FrameID
            if frameid in self.__translate:
                name = self.__translate[frameid]
                if frameid.startswith('T'):
                    for text in frame.text:
                        if text:
                            metadata.add(name, unicode(text))
github metabrainz / picard / picard / pluginmanager.py View on Github external
def zip_import(path):
    if (not is_zip(path) or not os.path.isfile(path)):
        return (None, None, None)
    try:
        zip_importer = zipimport.zipimporter(path)
        plugin_name = _plugin_name_from_path(path)
        manifest_data = None
        if is_zipped_package(path):
            try:
                manifest_data = load_manifest(path)
            except Exception as why:
                log.warning("Failed to load manifest data from json: %s", why)
        return (zip_importer, plugin_name, manifest_data)
    except zipimport.ZipImportError as why:
        log.error("ZIP import error: %s", why)
        return (None, None, None)
github metabrainz / picard / picard / track.py View on Github external
def _parse_recording(self, recording):
        m = self.metadata
        recording_to_metadata(recording, m, self)
        self.orig_metadata.copy(m)
        self._customize_metadata()
        run_track_metadata_processors(self.album, m, recording)
        for s_name, s_text in enabled_tagger_scripts_texts():
            parser = ScriptParser()
            try:
                parser.eval(s_text, m)
            except ScriptError:
                log.exception("Failed to run tagger script %s on track", s_name)
            m.strip_whitespace()

        self.loaded = True
        self.status = None
        if self.callback:
            self.callback()
            self.callback = None
        self.album.update(True)
github metabrainz / picard-plugins / plugins / musixmatch / __init__.py View on Github external
try:
        if error:
            log.error(error)
            return
        message = data.get('message', {})
        header = message.get('header')
        if header.get('status_code') != 200:
            log.warning('MusixMatch: Server returned no result: %s', data)
            return
        result = message.get('body', {}).get('lyrics')
        if result:
            lyrics = result.get('lyrics_body')
            if lyrics:
                metadata['lyrics:description'] = lyrics
    except AttributeError:
        log.error('MusixMatch: Error handling server response %s',
                  data, exc_info=True)
    finally:
        album._requests -= 1
        album._finalize_loading(error)