Ejemplo n.º 1
0
def generate(irc):
    try:
        openers    = get_list('text/opener')
        songs      = get_list('text/songs')
        piano      = get_list('text/piano')
        setclosers = get_list('text/setcloser')
        gigclosers = get_list('text/gigcloser')
    except IOError as e:
        print(e)

    randomset = {
        'main':    [],
        'encore1': [],
        'encore2': []
    }

    encorecount = random.randint(0, 1)

    construct_main_set(randomset, openers, songs, piano, setclosers)
    irc.msg(create_set_string(randomset['main']))

    if encorecount == 0:
        construct_single_encore(randomset, openers, songs, gigclosers)
        irc.msg("ENCORE: " + create_set_string(randomset['encore1']))
    else:
        construct_double_encore(randomset, openers, songs, setclosers, gigclosers)
        irc.msg("ENCORE 1: " + create_set_string(randomset['encore1']))
        irc.msg("ENCORE 2: " + create_set_string(randomset['encore2']))
Ejemplo n.º 2
0
def print_set_by_date(irc, date):
    date = date.replace('/', '-')

    try:
        qyear = year_value(date)
    except ValueError:
        irc.msg('Error: Invalid date format.')
        return

    database = filehandle.get_list('text/archive.db')
    for entry in database:
        if '::' not in entry:
            continue
        db_date = entry.split('::')[0]
        if date == db_date:
            db_file = entry.split('::')[1].strip()
            setlist = filehandle.get_list(db_file)
            irc.msg(setlist[0] + ':')

            setprint = txtfunctions.create_set_string(setlist[1:])
            irc.msg(setprint)
            return

    tours = sorted(os.listdir('GigArchive'))

    for tour in tours:
        if tour_in_range(tour, qyear):
            gigs = sorted(os.listdir('GigArchive/%s' % tour))
            for gig in gigs:
                if gig_date(gig) == date:
                    gig_file = 'GigArchive/%s/%s' % (tour, gig)
                    try:
                        setlist = filehandle.get_list(gig_file)
                    except IOError:
                        irc.msg('Error opening gig file.')
                        return
                    irc.msg(setlist[0] + ':')

                    setprint = txtfunctions.create_set_string(setlist[1:])
                    irc.msg(setprint)
                    if len(database) >= 100:
                        database.pop(0)
                    database.append('%s::%s' % (date, gig_file))
                    filehandle.put_list('text/archive.db', database)
                    return
    irc.msg('Could not find the gig from that date.')
Ejemplo n.º 3
0
def print_recent_setlist(irc):
    tours = sorted(os.listdir('GigArchive'))
    tour  = tours.pop()
    gigs  = sorted(os.listdir('GigArchive/%s' % tour))
    gig   = gigs.pop()

    setlist = filehandle.get_list('GigArchive/%s/%s' % (tour, gig))
    irc.msg('%s:' % setlist[0])

    setprint = txtfunctions.create_set_string(setlist[1:])
    irc.msg(setprint)