<commit_before>#-*- coding: utf-8 -*-
import re
from voiceplay.logger import logger
from .basetask import BasePlayerTask


class WhatTask(BasePlayerTask):

    __group__ = ['what']
    __regexp__ = ['^what are top albums (?:by|for) (.+)$',
                  '^what are top (?:songs|tracks) (?:by|for) (.+)$']
    __priority__ = 100
    __actiontype__ = 'what'

    @classmethod
    def process(cls, regexp, message):
        cls.logger.debug('Message: %r matches %r, running %r', message, regexp, cls.__name__)
        artist = re.match(regexp, message).groups()[0]
        if 'albums' in regexp:
            albums = cls.lfm.get_top_albums(artist)
            msg = cls.lfm.numerize(albums[:10])
            logger.warning('Here are top albums by %s - %s', artist, msg)
            cls.tts.say_put('Here are top albums by %s - %s' % (artist, msg))
        else:
            tracks = cls.lfm.get_top_tracks(artist)[:10]
            numerized = ', '.join(cls.lfm.numerize(tracks))
            reply = re.sub(r'^(.+)\.\s\d\:\s', '1: ', numerized)
            logger.warning('Here are some top tracks by %s: %s', artist, reply)
            cls.tts.say_put('Here are some top tracks by %s: %s' % (artist, reply))<commit_msg>date/time (q&d)<commit_after>#-*- coding: utf-8 -*-
import re
import time
from voiceplay.logger import logger
from .basetask import BasePlayerTask


class WhatTask(BasePlayerTask):

    __group__ = ['what']
    __regexp__ = ['^what are top albums (?:by|for) (.+)$',
                  '^what are top (?:songs|tracks) (?:by|for) (.+)$',
                  '^what time(.+)$', '^what (?:date|day)(.+)$',
                  '^(?:date|day)(.+)$']
    __priority__ = 100
    __actiontype__ = 'what'

    @classmethod
    def process(cls, regexp, message):
        cls.logger.debug('Message: %r matches %r, running %r', message, regexp, cls.__name__)
        artist = re.match(regexp, message).groups()[0]
        if 'albums' in regexp:
            albums = cls.lfm.get_top_albums(artist)
            msg = cls.lfm.numerize(albums[:10])
            logger.warning('Here are top albums by %s - %s', artist, msg)
            cls.tts.say_put('Here are top albums by %s - %s' % (artist, msg))
        elif 'songs' in regexp or 'tracks' in regexp:
            tracks = cls.lfm.get_top_tracks(artist)[:10]
            numerized = ', '.join(cls.lfm.numerize(tracks))
            reply = re.sub(r'^(.+)\.\s\d\:\s', '1: ', numerized)
            logger.warning('Here are some top tracks by %s: %s', artist, reply)
            cls.tts.say_put('Here are some top tracks by %s: %s' % (artist, reply))
        elif 'time' in regexp:
            cls.tts.say_put('It is %s %s right now' % (int(time.strftime('%H')), int(time.strftime('%M'))))
        elif 'date' in regexp or 'day' in regexp:
            weekday = time.strftime('%A')
            month_name = time.strftime('%B')
            daynum = int(time.strftime('%d'))
            cls.tts.say_put('It is %s %s %s' % (weekday, month_name, daynum))
{'fraction_non_alphanumeric': 0.17078052034689792, 'fraction_numerical': 0.0066711140760507, 'mean_word_length': 2.431350114416476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4098401', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1021, 'n_words': 256}