• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.colored_out函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.colored_out函数的典型用法代码示例。如果您正苦于以下问题:Python colored_out函数的具体用法?Python colored_out怎么用?Python colored_out使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了colored_out函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main(ENTITY_TYPE):

    entity_type_table = ENTITY_TYPE.replace('-', '_')
    url_relationship_table = 'l_%s_url' % entity_type_table if ENTITY_TYPE != 'work' else 'l_url_%s' % entity_type_table
    main_entity_entity_point = "entity0" if ENTITY_TYPE != 'work' else "entity1"
    url_entity_point = "entity1" if ENTITY_TYPE != 'work' else "entity0"

    query = """
    WITH
        entities_wo_wikidata AS (
            SELECT DISTINCT e.id AS entity_id, e.gid AS entity_gid, u.url AS wp_url, substring(u.url from '//(([a-z]|-)+)\\.') as wp_lang
            FROM """ + entity_type_table + """ e
                JOIN """ + url_relationship_table + """ l ON l.""" + main_entity_entity_point + """ = e.id AND l.link IN (SELECT id FROM link WHERE link_type = """ + str(WIKIPEDIA_RELATIONSHIP_TYPES[ENTITY_TYPE]) + """)
                JOIN url u ON u.id = l.""" + url_entity_point + """ AND u.url LIKE 'http://%%.wikipedia.org/wiki/%%'
            WHERE 
                /* No existing WikiData relationship for this entity */
                NOT EXISTS (SELECT 1 FROM """ + url_relationship_table + """ ol WHERE ol.""" + main_entity_entity_point + """ = e.id AND ol.link IN (SELECT id FROM link WHERE link_type = """ + str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE]) + """))
                /* WP link should only be linked to this entity */
                AND NOT EXISTS (SELECT 1 FROM """ + url_relationship_table + """ ol WHERE ol.""" + url_entity_point + """ = u.id AND ol.""" + main_entity_entity_point + """ <> e.id)
                AND l.edits_pending = 0
        )
    SELECT e.id, e.gid, e.name, ewf.wp_url, b.processed
    FROM entities_wo_wikidata ewf
    JOIN """ + entity_type_table + """ e ON ewf.entity_id = e.id
    LEFT JOIN bot_wp_wikidata_links b ON e.gid = b.gid AND b.lang = ewf.wp_lang
    ORDER BY b.processed NULLS FIRST, e.id
    LIMIT 500
    """

    seen = set()
    matched = set()
    for entity in db.execute(query):
        if entity['gid'] in matched:
            continue

        colored_out(bcolors.OKBLUE, 'Looking up entity "%s" http://musicbrainz.org/%s/%s' % (entity['name'], ENTITY_TYPE, entity['gid']))
        out(' * wiki:', entity['wp_url'])

        page = WikiPage.fetch(entity['wp_url'], False)
        if page.wikidata_id:
            wikidata_url = 'http://www.wikidata.org/wiki/%s' % page.wikidata_id.upper()
            edit_note = 'From %s' % (entity['wp_url'],)
            colored_out(bcolors.OKGREEN, ' * found WikiData identifier:', wikidata_url)
            time.sleep(1)
            out(' * edit note:', edit_note.replace('\n', ' '))
            mb.add_url(ENTITY_TYPE.replace('-', '_'), entity['gid'], str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE]), wikidata_url, edit_note, True)
            matched.add(entity['gid'])

        if entity['processed'] is None and entity['gid'] not in seen:
            db.execute("INSERT INTO bot_wp_wikidata_links (gid, lang) VALUES (%s, %s)", (entity['gid'], page.lang))
        else:
            db.execute("UPDATE bot_wp_wikidata_links SET processed = now() WHERE (gid, lang) = (%s, %s)", (entity['gid'], page.lang))
        seen.add(entity['gid'])
    stats['seen'][ENTITY_TYPE] = len(seen)
    stats['matched'][ENTITY_TYPE] = len(matched)
开发者ID:tommycrock,项目名称:musicbrainz-bot,代码行数:55,代码来源:wp_wikidata_links.py


示例2: submit_cover_art

def submit_cover_art(release, url, types):
    if already_processed(release, url):
        colored_out(bcolors.NONE, " * skipping already submitted image '%s'" % (url,))
    else:
        colored_out(bcolors.OKGREEN, " * Adding " + ",".join(types) + (" " if len(types)>0 else "") + "cover art '%s'" % (url,))
        img_file = urllib2.urlopen(url)
        im = Image.open(StringIO(img_file.read()))
        edit_note = "'''Dimension''': %sx%s\n'''Source''': %s" % (im.size[0], im.size[1], url)
        time.sleep(5)
        mb.add_cover_art(release, url, types, None, u'', edit_note, False)
        save_processed(release, url)
开发者ID:Sophist-UK,项目名称:Sophist_musicbrainz-bot,代码行数:11,代码来源:discogs_cover_art.py


示例3: submit_cover_art

def submit_cover_art(release, url, types):
    if already_processed(release, url):
        colored_out(bcolors.NONE, " * skipping already submitted image '%s'" % (url,))
    else:
        colored_out(bcolors.OKGREEN, " * Adding " + ",".join(types) + (" " if len(types) > 0 else "") + "cover art '%s'" % (url,))
        content = urllib2.urlopen(url).read()
        image_file = tempfile.NamedTemporaryFile(delete=False)
        image_file.write(content)
        image_file.close()
        im = Image.open(image_file.name)
        edit_note = "'''Dimension''': %sx%s\n'''Source''': %s" % (im.size[0], im.size[1], url)
        time.sleep(5)
        mb.add_cover_art(release, image_file.name, types, None, u'', edit_note, False)
        os.remove(image_file.name)
        save_processed(release, url)
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:15,代码来源:discogs_cover_art.py


示例4: submit_cover_art

def submit_cover_art(release, url, types):
    if already_processed(release, url):
        colored_out(bcolors.NONE, " * skipping already submitted image '%s'" % (url,))
    else:
        colored_out(bcolors.OKGREEN, " * Adding " + ",".join(types) + (" " if len(types) > 0 else "") + "cover art '%s'" % (url,))
        if 'discogs' in url:
            headers = {'user-agent': 'MusicBrainzBot/0.1 +https://github.com/murdos/musicbrainz-bot'}
            resp, content = discogs_oauth_client.request(url, 'GET', headers=headers)
        else:
            content = urllib2.urlopen(url).read()
        image_file = tempfile.NamedTemporaryFile(delete=False)
        image_file.write(content)
        image_file.close()
        im = Image.open(image_file.name)
        edit_note = "'''Dimension''': %sx%s\n'''Source''': %s" % (im.size[0], im.size[1], url)
        time.sleep(5)
        mb.add_cover_art(release, image_file.name, types, None, u'', edit_note, False)
        os.remove(image_file.name)
        save_processed(release, url)
开发者ID:legoktm,项目名称:musicbrainz-bot,代码行数:19,代码来源:discogs_cover_art.py


示例5: determine_country

def determine_country(page):
    all_countries = set()
    all_reasons = []
    countries, reason = determine_country_from_infobox(page)
    if countries:
        all_countries.update(countries)
        all_reasons.append(reason)
    countries, reason = determine_country_from_text(page)
    if countries:
        all_countries.update(countries)
        all_reasons.append(reason)
    countries, reason, category_count = determine_country_from_categories(page)
    has_categories = False
    if countries:
        all_countries.update(countries)
        all_reasons.append(reason)
        has_categories = True
    if len(all_reasons) < 1 or not all_countries or not has_categories:
        colored_out(bcolors.WARNING, ' * not enough sources for countries', all_countries, all_reasons)
        return None, []
    if len(all_countries) > 1:
        colored_out(bcolors.FAIL, ' * conflicting countries', all_countries, all_reasons)
        return None, []
    country = list(all_countries)[0]
    colored_out(bcolors.OKGREEN, ' * new country: ', country)
    return country, all_reasons
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:26,代码来源:analysis.py


示例6: discogs_get_release_packaging

def discogs_get_release_packaging(discogs_release):
    #if len(discogs_release.data['formats']) > 1:
    #    return None
    for format in discogs_release.data['formats']:

        if 'text' not in format:
            print 'No text found for format %s' % format['name']
            continue
        
        freetext = format['text'].lower().replace('-', '').replace(' ', '')
        colored_out(bcolors.HEADER, ' * Discogs format text: %s' % freetext)
        if 'cardboard' in freetext or 'paper' in freetext:
            return "cardboard/paper sleeve";
        elif 'digipak' in freetext or 'digipack' in freetext:
            return "digipak";
        elif 'keepcase' in freetext:
            return "keep case";
        elif 'jewel' in freetext:
            if 'slim' in freetext:
                return "slim jewel case"
            else:
                return "jewel case"

    return None
开发者ID:tommycrock,项目名称:musicbrainz-bot,代码行数:24,代码来源:discogs_release_packaging.py


示例7: determine_type

def determine_type(page):
    all_types = set()
    all_reasons = []
    types, reason = determine_type_from_page(page)
    if types:
        all_types.update(types)
        all_reasons.append(reason)
    if not all_reasons:
        colored_out(bcolors.WARNING, ' * not enough sources for types')
        return None, []
    if len(all_types) > 1:
        colored_out(bcolors.FAIL, ' * conflicting types', all_types, all_reasons)
        return None, []
    type = list(all_types)[0]
    colored_out(bcolors.OKGREEN, ' * new type:', type)
    return type, all_reasons
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:16,代码来源:analysis.py


示例8: determine_gender

def determine_gender(page):
    all_genders = set()
    all_reasons = []
    genders, reason = determine_gender_from_firstname(page)
    if genders:
        all_genders.update(genders)
        all_reasons.append(reason)
    genders, reason = determine_gender_from_categories(page)
    if genders:
        all_genders.update(genders)
        all_reasons.append(reason)
    genders, reason = determine_gender_from_text(page)
    if genders:
        all_genders.update(genders)
        all_reasons.append(reason)
    if not all_reasons:
        colored_out(bcolors.WARNING, ' * not enough sources for genders')
        return None, []
    if len(all_genders) > 1:
        colored_out(bcolors.FAIL, ' * conflicting genders', all_genders, all_reasons)
        return None, []
    gender = list(all_genders)[0]
    colored_out(bcolors.OKGREEN, ' * new gender:', gender)
    return gender, all_reasons
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:24,代码来源:analysis.py


示例9: artist

      JOIN l_recording_work lrw ON recording.id = lrw.entity0
      JOIN l_artist_work law ON lrw.entity1 = law.entity1
     WHERE acn.artist = %s
    UNION
    -- Select artists of recordings of works for this artist (i.e. performers of works this artist wrote)
    SELECT acn.artist AS artist
      FROM artist_credit_name acn
      JOIN recording ON acn.artist_credit = recording.artist_credit
      JOIN l_recording_work lrw ON recording.id = lrw.entity0
      JOIN l_artist_work law ON lrw.entity1 = law.entity1
     WHERE law.entity0 = %s
)
"""

for artist in db.execute(query, query_params):
    colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))
    matches = wps.query(escape_query(artist['name']), defType='dismax', qf='name', rows=50).results
    last_wp_request = time.time()
    for match in matches:
        title = match['name']
        if title.endswith('album)') or title.endswith('song)'):
            continue
        if mangle_name(re.sub(' \(.+\)$', '', title)) != mangle_name(artist['name']) and mangle_name(title) != mangle_name(artist['name']):
            continue
        delay = time.time() - last_wp_request
        if delay < 1.0:
            time.sleep(1.0 - delay)
        last_wp_request = time.time()
        wikipage = WikiPage.fetch('https://%s.wikipedia.org/wiki/%s' % (wp_lang, title))
        page_orig = wikipage.text
        if not page_orig:
开发者ID:digideskio,项目名称:musicbrainz-bot,代码行数:31,代码来源:wp_links_artists.py


示例10: set

    )
SELECT a.id, a.gid, a.name, aws.shs_url, aws.work_id, aws.work_gid, b.processed
FROM artists_wo_shs aws
JOIN s_artist a ON aws.artist_id = a.id
LEFT JOIN bot_shs_link_artist b ON a.gid = b.artist
ORDER BY b.processed NULLS FIRST, a.id
LIMIT 1000
"""

seen_artists = set()
matched_artists = set()
for artist in db.execute(query):
    if artist['gid'] in matched_artists:
        continue

    colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))

    m = re.match(r'http://www.secondhandsongs.com/work/([0-9]+)', artist['shs_url'])
    if m:
        shs_work = shs.lookup_work(int(m.group(1)))
    else:
        continue
    
    artist_uri = None
    shs_artists = []
    # credits of actual work
    if 'credits' in shs_work and len(shs_work['credits']) > 0:
        shs_artists.extend(shs_work['credits'])
    # credits of original work
    if 'originalCredits' in shs_work and len(shs_work['originalCredits']) > 0:
        shs_artists.extend(shs_work['originalCredits'])
开发者ID:Sophist-UK,项目名称:Sophist_musicbrainz-bot,代码行数:31,代码来源:shs_link_artist.py


示例11: main

def main():
    seen = set()
    matched = set()
    for artist in db.execute(query):
        if artist['gid'] in matched:
            continue

        colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))
        out(' * wiki:', artist['wp_url'])

        page = WikiPage.fetch(artist['wp_url'], False)
        identifiers = determine_authority_identifiers(page)
        if 'VIAF' in identifiers:
            if not isinstance(identifiers['VIAF'], basestring):
                colored_out(bcolors.FAIL, ' * multiple VIAF found: %s' % ', '.join(identifiers['VIAF']))
            elif identifiers['VIAF'] == '' or identifiers['VIAF'] is None:
                colored_out(bcolors.FAIL, ' * invalid empty VIAF found')
            else:
                viaf_url = 'http://viaf.org/viaf/%s' % identifiers['VIAF']
                edit_note = 'From %s' % (artist['wp_url'],)
                colored_out(bcolors.OKGREEN, ' * found VIAF:', viaf_url)
                # Check if this VIAF has not been deleted
                skip = False
                try:
                    resp, content = httplib2.Http().request(viaf_url)
                except socket.error:
                    colored_out(bcolors.FAIL, ' * timeout!')
                    skip = True
                deleted_message = 'abandonedViafRecord'
                if skip == False and (resp.status == '404' or deleted_message in content):
                    colored_out(bcolors.FAIL, ' * deleted VIAF!')
                    skip = True
                if skip == False:
                    time.sleep(3)
                    out(' * edit note:', edit_note.replace('\n', ' '))
                    mb.add_url('artist', artist['gid'], str(VIAF_RELATIONSHIP_TYPES['artist']), viaf_url, edit_note)
                    matched.add(artist['gid'])

        if artist['processed'] is None and artist['gid'] not in seen:
            db.execute("INSERT INTO bot_wp_artist_viaf (gid, lang) VALUES (%s, %s)", (artist['gid'], page.lang))
        else:
            db.execute("UPDATE bot_wp_artist_viaf SET processed = now() WHERE (gid, lang) = (%s, %s)", (artist['gid'], page.lang))
        seen.add(artist['gid'])
开发者ID:legoktm,项目名称:musicbrainz-bot,代码行数:43,代码来源:wp_artist_viaf.py


示例12: EXISTS

        AND NOT EXISTS (SELECT 1 FROM l_recording_work lrw2 WHERE lrw2.entity0 = r.id AND lrw2.entity1 <> lrw.entity1)
    ORDER BY r.artist_credit
    LIMIT 750
"""

date_re = re.compile(r'live, (\d{4})(?:-(\d{2}))?(?:-(\d{2}))?:', re.I)
for recording in db.execute(query):

    m = re.match(date_re, recording['comment'])
    if m is None:
        continue

    date = {'year': int(m.group(1))}

    if m.group(2) is not None:
        date['month'] = int(m.group(2))
    if m.group(3) is not None:
        date['day'] = int(m.group(3))
  
    colored_out(bcolors.OKBLUE, 'Setting performance relationships dates of http://musicbrainz.org/recording/%s "%s (%s)"' % (recording['r_gid'], recording['name'], recording['comment']))

    attributes = {}
    edit_note = 'Setting relationship dates from recording comment: "%s"' % recording['comment']
    colored_out(bcolors.NONE, " * new date:", date)
    
    entity0 = {'type': 'recording', 'gid': recording['r_gid']}
    entity1 = {'type': 'work', 'gid': recording['w_gid']}

    time.sleep(2)
    mb.edit_relationship(recording['rel_id'], entity0, entity1, recording['link_type'], attributes, date, date, edit_note, True)
开发者ID:legoktm,项目名称:musicbrainz-bot,代码行数:30,代码来源:live_recordings_dates.py


示例13: main

def main(ENTITY_TYPE):

    entity_type_table = ENTITY_TYPE.replace("-", "_")
    url_relationship_table = "l_%s_url" % entity_type_table if ENTITY_TYPE != "work" else "l_url_%s" % entity_type_table
    main_entity_entity_point = "entity0" if ENTITY_TYPE != "work" else "entity1"
    url_entity_point = "entity1" if ENTITY_TYPE != "work" else "entity0"

    query = (
        """
    WITH
        entities_wo_wikidata AS (
            SELECT DISTINCT e.id AS entity_id, e.gid AS entity_gid, u.url AS wp_url
            FROM """
        + entity_type_table
        + """ e
                JOIN """
        + url_relationship_table
        + """ l ON l."""
        + main_entity_entity_point
        + """ = e.id AND l.link IN (SELECT id FROM link WHERE link_type = """
        + str(WIKIPEDIA_RELATIONSHIP_TYPES[ENTITY_TYPE])
        + """)
                JOIN url u ON u.id = l."""
        + url_entity_point
        + """ AND u.url LIKE 'http://%%.wikipedia.org/wiki/%%' AND substring(u.url from 8 for 2) IN ('en', 'fr')
            WHERE 
                /* No existing WikiData relationship for this entity */
                NOT EXISTS (SELECT 1 FROM """
        + url_relationship_table
        + """ ol WHERE ol."""
        + main_entity_entity_point
        + """ = e.id AND ol.link IN (SELECT id FROM link WHERE link_type = """
        + str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE])
        + """))
                /* WP link should only be linked to this entity */
                AND NOT EXISTS (SELECT 1 FROM """
        + url_relationship_table
        + """ ol WHERE ol."""
        + url_entity_point
        + """ = u.id AND ol."""
        + main_entity_entity_point
        + """ <> e.id)
                AND l.edits_pending = 0
        )
    SELECT e.id, e.gid, e.name, ewf.wp_url, b.processed
    FROM entities_wo_wikidata ewf
    JOIN s_"""
        + entity_type_table
        + """ e ON ewf.entity_id = e.id
    LEFT JOIN bot_wp_wikidata_links b ON e.gid = b.gid AND b.lang = substring(ewf.wp_url from 8 for 2)
    ORDER BY b.processed NULLS FIRST, e.id
    LIMIT 250
    """
    )

    seen = set()
    matched = set()
    for entity in db.execute(query):
        if entity["gid"] in matched:
            continue

        colored_out(
            bcolors.OKBLUE,
            'Looking up entity "%s" http://musicbrainz.org/%s/%s' % (entity["name"], ENTITY_TYPE, entity["gid"]),
        )
        out(" * wiki:", entity["wp_url"])

        page = WikiPage.fetch(entity["wp_url"], False)
        if page.wikidata_id:
            wikidata_url = "http://www.wikidata.org/wiki/%s" % page.wikidata_id.upper()
            edit_note = "From %s" % (entity["wp_url"],)
            colored_out(bcolors.OKGREEN, " * found WikiData identifier:", wikidata_url)
            time.sleep(3)
            out(" * edit note:", edit_note.replace("\n", " "))
            mb.add_url(
                ENTITY_TYPE.replace("-", "_"),
                entity["gid"],
                str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE]),
                wikidata_url,
                edit_note,
                True,
            )
            matched.add(entity["gid"])

        if entity["processed"] is None and entity["gid"] not in seen:
            db.execute("INSERT INTO bot_wp_wikidata_links (gid, lang) VALUES (%s, %s)", (entity["gid"], page.lang))
        else:
            db.execute(
                "UPDATE bot_wp_wikidata_links SET processed = now() WHERE (gid, lang) = (%s, %s)",
                (entity["gid"], page.lang),
            )
        seen.add(entity["gid"])
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:92,代码来源:wp_wikidata_links.py


示例14: main

def main():
    seen = set()
    for artist in db.execute(query):
        if artist['id'] in seen:
            continue
        seen.add(artist['id'])
        colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))
        out(' * wiki:', artist['url'])

        artist = dict(artist)
        update = set()
        reasons = []

        page = WikiPage.fetch(artist['url'])

        if not artist['country']:
            country, country_reasons = determine_country(page)
            if country:
                country_id = country_ids[country]
                artist['country'] = country_id
                update.add('country')
                reasons.append(('COUNTRY', country_reasons))

        if not artist['type']:
            type, type_reasons = determine_type(page)
            if type:
                type_id = artist_type_ids[type]
                artist['type'] = type_id
                update.add('type')
                reasons.append(('TYPE', type_reasons))

        if not artist['gender'] and artist['type'] == 1:
            gender, gender_reasons = determine_gender(page)
            if gender:
                gender_id = gender_ids[gender]
                artist['gender'] = gender_id
                update.add('gender')
                reasons.append(('GENDER', gender_reasons))

        is_performance_name = False
        if artist['type'] == 1 and CHECK_PERFORMANCE_NAME:
            is_performance_name = db.execute(performance_name_query, artist['id']).scalar() > 0
            out(" * checking for performance name", is_performance_name)

        if not artist['begin_date_year']:
            begin_date, begin_date_reasons = determine_begin_date(artist, page, is_performance_name)
            if begin_date['year']:
                colored_out(bcolors.OKGREEN, " * new begin date:", begin_date)
                artist['begin_date_year'] = begin_date['year']
                artist['begin_date_month'] = begin_date['month']
                artist['begin_date_day'] = begin_date['day']
                update.add('begin_date')
                reasons.append(('BEGIN DATE', begin_date_reasons))
        if not artist['end_date_year']:
            end_date, end_date_reasons = determine_end_date(artist, page, is_performance_name)
            if end_date['year']:
                colored_out(bcolors.OKGREEN, " * new end date:", end_date)
                artist['end_date_year'] = end_date['year']
                artist['end_date_month'] = end_date['month']
                artist['end_date_day'] = end_date['day']
                update.add('end_date')
                reasons.append(('END DATE', end_date_reasons))

        if update:
            edit_note = 'From %s' % (artist['url'],)
            for field, reason in reasons:
                edit_note += '\n\n%s:\n%s' % (field, ' '.join(reason))
            out(' * edit note:', edit_note.replace('\n', ' '))
            time.sleep(10)
            mb.edit_artist(artist, update, edit_note)

        db.execute("INSERT INTO bot_wp_artist_data (gid, lang) VALUES (%s, %s)", (artist['gid'], wp_lang))
        out()
开发者ID:Jokipii,项目名称:musicbrainz-bot,代码行数:73,代码来源:wp_artist_country.py


示例15: colored_out

DISCOGS_MB_FORMATS_MAPPING = {
    "Vinyl": 7,
    '12"': 31,
    '10"': 30,
    '7"': 29,
    "CD": 1,
    "CDr": 33,
    "Cassette": 8,
    "DigitalMedia": 12,
}

for medium in db.execute(query):
    colored_out(
        bcolors.OKBLUE,
        'Looking up medium #%s of release "%s" by "%s" http://musicbrainz.org/release/%s'
        % (medium["position"], medium["name"], medium["ac_name"], medium["gid"]),
    )

    m = re.match(r"http://www.discogs.com/release/([0-9]+)", medium["discogs_url"])
    if m:
        discogs_release = discogs.Release(int(m.group(1)))

    discogs_format = discogs_get_medium_format(discogs_release, medium["position"])
    if discogs_format:
        colored_out(bcolors.HEADER, " * using %s, found format: %s" % (medium["discogs_url"], discogs_format))
        edit_note = "Setting medium format from attached Discogs link (%s)" % medium["discogs_url"]
        out(" * edit note: %s" % (edit_note,))
        mb.set_release_medium_format(
            medium["gid"],
            medium["position"],
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:30,代码来源:discogs_medium_format.py


示例16: AS

    releases_wo_7inch AS (
        SELECT r.id, u.url, m.format
        FROM release r
            JOIN medium m ON m.release = r.id
            JOIN l_release_url l ON l.entity0 = r.id AND l.link IN (SELECT id FROM link WHERE link_type = 78)
            JOIN url u ON u.id = l.entity1
        WHERE u.url LIKE 'http://www.encyclopedisque.fr/images/%%'
            AND (m.format IS NULL OR m.format = 7)
            AND NOT EXISTS (SELECT 1 FROM l_release_url WHERE l_release_url.entity1 = u.id AND l_release_url.entity0 <> r.id)
    )
SELECT r.id, r.gid, r.name, ta.url, ta.format, ac.name
FROM releases_wo_7inch ta
JOIN s_release r ON ta.id = r.id
JOIN s_artist_credit ac ON r.artist_credit=ac.id
LEFT JOIN bot_encyclopedisque_medium_format b ON r.gid = b.gid
WHERE b.gid IS NULL
ORDER BY r.artist_credit, r.id
LIMIT 100
"""

for id, gid, name, url, format, ac_name in db.execute(query):
    colored_out(bcolors.OKBLUE, 'Looking up release "%s" by "%s" http://musicbrainz.org/release/%s' % (name, ac_name, gid))

    edit_note = 'Setting format to 7" based on attached link to Encyclopedisque (%s)' % url
    out(' * edit note: %s' % (edit_note,))
    mb.set_release_medium_format(gid, format, 29, edit_note)

    time.sleep(5)

    db.execute("INSERT INTO bot_encyclopedisque_medium_format (gid) VALUES (%s)", (gid,))
开发者ID:Jokipii,项目名称:musicbrainz-bot,代码行数:30,代码来源:encyclopedisque_medium_format.py


示例17: colored_out

"""

query_artist_albums = """
SELECT rg.name
FROM s_release_group rg
JOIN artist_credit_name acn ON rg.artist_credit = acn.artist_credit
WHERE acn.artist = %s
UNION
SELECT r.name
FROM s_release r
JOIN artist_credit_name acn ON r.artist_credit = acn.artist_credit
WHERE acn.artist = %s
"""

for artist in db.execute(query, query_params):
    colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))
    matches = wps.query(escape_query(artist['name']), defType='dismax', qf='name', rows=50).results
    last_wp_request = time.time()
    for match in matches:
        title = match['name']
        if title.endswith('album)') or title.endswith('song)'):
            continue
        if mangle_name(re.sub(' \(.+\)$', '', title)) != mangle_name(artist['name']) and mangle_name(title) != mangle_name(artist['name']):
            continue
        delay = time.time() - last_wp_request
        if delay < 1.0:
            time.sleep(1.0 - delay)
        last_wp_request = time.time()
        wikipage = WikiPage.fetch('http://%s.wikipedia.org/wiki/%s' % (wp_lang, title))
        page_orig = wikipage.text
        if not page_orig:
开发者ID:Jokipii,项目名称:musicbrainz-bot,代码行数:31,代码来源:wp_links_artists.py


示例18: colored_out

 "German": 145,
 "Greek": 159,
 "Italian": 195,
 "Japanese": 198,
 "[Multiple languages]": 284,
 "Norwegian": 309,
 "Polish": 338,
 "Portuguese": 340,
 "Russian": 353,
 "Spanish": 393,
 "Swedish": 403,
 "Turkish": 433,
}

for work in db.execute(query):
    colored_out(bcolors.OKBLUE, 'Looking up work "%s" http://musicbrainz.org/work/%s' % (work['name'], work['gid']))

    m = re.match(r'http://www.secondhandsongs.com/work/([0-9]+)', work['shs_url'])
    if m:
        shs_work = shs.lookup_work(int(m.group(1)))
    else:
        continue
        
    if 'language' in shs_work:
        work = dict(work)
        shs_lang = shs_work['language']
        
        if shs_lang not in SHS_MB_LANG_MAPPING:
            colored_out(bcolors.FAIL, ' * No mapping defined for language ''%s' % shs_lang)
        else:
            work['iswcs'] = []
开发者ID:Sophist-UK,项目名称:Sophist_musicbrainz-bot,代码行数:31,代码来源:shs_work_lang.py


示例19: int

for recording in db.execute(query):

    m = re.match(date_re, recording["comment"])
    if m is None:
        continue

    date = {"year": int(m.group(1))}

    if m.group(2) is not None:
        date["month"] = int(m.group(2))
    if m.group(3) is not None:
        date["day"] = int(m.group(3))

    colored_out(
        bcolors.OKBLUE,
        'Setting performance relationships dates of http://musicbrainz.org/recording/%s "%s (%s)"'
        % (recording["gid"], recording["name"], recording["comment"]),
    )

    attributes = {}
    edit_note = 'Setting relationship dates from recording comment: "%s"' % recording["comment"]
    colored_out(bcolors.NONE, " * new date:", date)

    time.sleep(15)
    mb.edit_relationship(
        recording["rel_id"],
        "recording",
        "work",
        recording["link_type"],
        recording["link_type"],
        attributes,
开发者ID:weisslj,项目名称:musicbrainz-bot,代码行数:31,代码来源:live_recordings_dates.py


示例20: colored_out

import hashlib
import base64
from utils import structureToString, colored_out, bcolors
from datetime import datetime
from mbbot.guesscase import guess_artist_sort_name

# Optional modules
try:
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.common.exceptions import NoSuchElementException, ElementNotVisibleException
except ImportError as err:
    colored_out(bcolors.WARNING, "Warning: Cannot use Selenium Webdriver client: %s" % err)
    webdriver = None

try:
    from pyvirtualdisplay import Display
except ImportError as err:
    colored_out(bcolors.WARNING, "Warning: Cannot run Selenium Webdriver client in headless mode: %s" % err)
    Display = None

def format_time(secs):
    return '%0d:%02d' % (secs // 60, secs % 60)


def album_to_form(album):
    form = {}
    form['artist_credit.names.0.artist.name'] = album['artist']
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:31,代码来源:editing.py



注:本文中的utils.colored_out函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.combo_get_value函数代码示例发布时间:2022-05-26
下一篇:
Python utils.color_hex_to_cairo函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap