Example #1
0
def handle_sessions(args):
    conn, path = instantiate_db(True)

    session_records = db.show_sessions(conn, active = not args.inactive,
            session_year = None if args.year == 0 else int(args.year),
            status = 'stuck' if args.stuck else None)

    columns = ['title', 'started']
    if(args.column):
        columns.extend(args.column)
    print(rp.format_records(session_records, columns,
        header=True,nums=True))
Example #2
0
def handle_search(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]
    annotate_platforms(conn, games)
    columns = ['title', 'via', 'platforms', 'release_year']

    if args.passes:
        columns.append('passes')
    if args.eternal:
        columns.append('eternal')
    
    print(rp.format_records(games, columns, header=True))
Example #3
0
def handle_sessions(args):
    conn, path = instantiate_db(True)

    session_records = db.show_sessions(
        conn,
        active=not args.inactive,
        session_year=None if args.year == 0 else int(args.year),
        status='stuck' if args.stuck else None)

    columns = ['title', 'started']
    if (args.column):
        columns.extend(args.column)
    print(rp.format_records(session_records, columns, header=True, nums=True))
Example #4
0
def handle_search(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]
    annotate_platforms(conn, games)
    columns = ['title', 'via', 'platforms', 'release_year']

    if args.passes:
        columns.append('passes')
    if args.eternal:
        columns.append('eternal')

    print(rp.format_records(games, columns, header=True))
Example #5
0
def handle_finish(conn):
    conn, path = instantiate_db(True)

    sessions = db.show_sessions(conn, active=True)
    print(
        rp.format_records(sessions, ['title', 'started'],
                          header=True,
                          nums=True))

    finish = input('Input a session to finish, or Q to abort: ')
    if finish == 'q' or finish == 'Q':
        return
    finish = int(finish)

    finish_session = sessions[finish - 1]
    status = input('Was %s a transient (t) or sticking (s) experience: ' %
                   finish_session['title'])
    if status == 'q' or status == 'Q':
        return

    status = 'transient' if status == 't' or status == 'T' else 'stuck'

    # TODO: allow delays
    more = input('''How long until %s should be suggested again?
1) any time
2) one month
3) three months
4) one year
5) done forever
q) abort
Input response: ''' % finish_session['title'])
    if more == 'q' or more == 'Q':
        return

    if int(more) == 2:
        db.set_next_valid_date(conn, finish_session['game_id'],
                               date.today() + datetime.timedelta(days=31))
    elif int(more) == 3:
        db.set_next_valid_date(conn, finish_session['game_id'],
                               date.today() + datetime.timedelta(days=92))
    elif int(more) == 4:
        db.set_next_valid_date(conn, finish_session['game_id'],
                               date.today() + datetime.timedelta(days=365))
    elif int(more) == 5:
        db.retire_game(conn, finish_session['game_id'])

    db.finish_session(conn, finish_session['game_id'], status)

    db.dump_csvs(conn, path)
Example #6
0
def handle_finish(conn):
    conn, path = instantiate_db(True)

    sessions = db.show_sessions(conn, active = True)
    print(rp.format_records(sessions,
        ['title', 'started'],
        header=True,nums=True))

    finish = input('Input a session to finish, or Q to abort: ')
    if finish == 'q' or finish == 'Q':
        return
    finish = int(finish)

    finish_session = sessions[finish - 1]
    status = input('Was %s a transient (t) or sticking (s) experience: ' % finish_session['title'])
    if status == 'q' or status == 'Q':
        return

    status = 'transient' if status == 't' or status == 'T' else 'stuck'

    # TODO: allow delays
    more = input('''How long until %s should be suggested again?
1) any time
2) one month
3) three months
4) one year
5) done forever
q) abort
Input response: ''' % finish_session['title'])
    if more == 'q' or more == 'Q':
        return

    if int(more) == 2:
        db.set_next_valid_date(conn, finish_session['game_id'],
            date.today() + datetime.timedelta(days = 31))
    elif int(more) == 3:
        db.set_next_valid_date(conn, finish_session['game_id'],
            date.today() + datetime.timedelta(days = 92))
    elif int(more) == 4:
        db.set_next_valid_date(conn, finish_session['game_id'],
            date.today() + datetime.timedelta(days = 365))
    elif int(more) == 5:
        db.retire_game(conn, finish_session['game_id'])

    db.finish_session(conn, finish_session['game_id'], status)

    db.dump_csvs(conn, path)
Example #7
0
def handle_starts(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game?')
    print(rp.format_records(games, ['title'], header=True, nums=True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])
    db.create_session(conn, gid)

    print('Created session for %s' % (title))

    db.dump_csvs(conn, path)
Example #8
0
def handle_reset(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game to reset?')
    print(rp.format_records(games, ['title'], nums=True, header=True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])

    db.reset_selectability(conn, gid)
    print('Reset selectability for %s' % (title))

    db.dump_csvs(conn, path)
Example #9
0
def handle_starts(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game?')
    print(rp.format_records(games,
        ['title'],
        header = True, nums = True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])
    db.create_session(conn, gid)

    print('Created session for %s' % (title))

    db.dump_csvs(conn, path)
Example #10
0
def handle_reset(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game to reset?')
    print(rp.format_records(games,
        ['title'],
        nums = True,header = True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])

    db.reset_selectability(conn, gid);
    print('Reset selectability for %s' % (title))

    db.dump_csvs(conn, path)
Example #11
0
def handle_own(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game now owned?')
    print(rp.format_records(games, ['title'], nums=True, header=True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])

    plat = input('Name of platformed purchased on: ')
    db.add_ownership(conn, gid, plat)

    print('Added %s platform for %s' % (plat, title))

    db.dump_csvs(conn, path)
Example #12
0
def handle_own(args):
    conn, path = instantiate_db(True)

    games = db.search_game(conn, args.title)[:5]

    print('Which game now owned?')
    print(rp.format_records(games,
        ['title'],
        nums = True,header = True))

    which_game = input('Input number, or q to abort: ')
    if which_game.lower() == 'q':
        return

    gid, title = (games[int(which_game) - 1]['id'],
                  games[int(which_game) - 1]['title'])

    plat = input('Name of platformed purchased on: ')
    db.add_ownership(conn, gid, plat)

    print('Added %s platform for %s' % (plat, title))

    db.dump_csvs(conn, path)
Example #13
0
def handle_select(args):
    conn, path = instantiate_db(True)

    passed_ids = []
    while True:
        owned = True
        if args.buy:
            owned = None
        if args.buy_only:
            owned = False

        games = db.select_random_games(conn, n = args.n, before_this_year = True if args.old else None,
                linux = True if args.linux else None, couch = True if args.couch else None,
                owned = owned, max_passes = args.max_passes,
                exclude_ids = passed_ids, storefront = args.storefront)

        annotate_platforms(conn, games)
        print(rp.format_records(games,
            ['title', 'linux', 'couch', 'platforms', 'via'],
            header = True, nums = True))

        # If we're just displaying a selection, finish here
        if not args.pick:
            break

        print('\nChoose a game to create a new active session for. Input 0 to pass on all games. Q to abort.')
        selection = input("Selection: ")

        if selection == 'q' or selection == 'Q':
            break

        selection = int(selection)

        if selection == 0:
            # Increment the pass counter on each game
            for game in games:
                # Don't propose game again
                passed_ids.append(game['id'])

                # If eternal still undecided 
                # give option to make eternal
                if game['eternal'] is None:
                    eternal = input('Should this game never stop being proposed? Y/N/P[ass]: ')
                    if eternal == 'Y' or eternal == 'y':
                        db.set_eternal(conn, game['id'], 1)
                    elif eternal  == 'N' or eternal == 'n':
                        db.set_eternal(conn, game['id'], 0)


                # If the game is not out yet, don't increment
                if game['release_year'] != None and game['release_year'] != '' and int(game['release_year']) == date.today().year:
                    freebie = input('%s was released this year. Has it been released? Y/N: ' % game['title'])
                    if freebie == 'N' or freebie == 'n':
                        continue
                new_passes = db.inc_pass(conn, game['id'])

                # Delay next possible proposal according to passes
                if new_passes == 1:
                    db.set_next_valid_date(conn, game['id'],
                        date.today() + datetime.timedelta(days = 7))
                elif new_passes == 2:
                    db.set_next_valid_date(conn, game['id'],
                        date.today() + datetime.timedelta(days = 30))
                else:
                    db.set_next_valid_date(conn, game['id'],
                        date.today() + datetime.timedelta(days = 90))
                
        else:
            # Create an active session
            game = games[selection - 1]
            db.create_session(conn, game['id'])
            print('Created a new session of %s.' % game['title'])
            break

        print('\n')

    # So scared of commitment
    db.dump_csvs(conn, path)
Example #14
0
def handle_select(args):
    conn, path = instantiate_db(True)

    passed_ids = []
    while True:
        owned = True
        if args.buy:
            owned = None
        if args.buy_only:
            owned = False

        games = db.select_random_games(
            conn,
            n=args.n,
            before_this_year=True if args.old else None,
            linux=True if args.linux else None,
            couch=True if args.couch else None,
            portable=True if args.portable else None,
            owned=owned,
            max_passes=args.max_passes,
            exclude_ids=passed_ids,
            storefront=args.storefront)

        annotate_platforms(conn, games)
        print("")
        print(
            rp.format_records(
                games,
                ['title', 'linux', 'couch', 'portable', 'platforms', 'via'],
                header=True,
                nums=True))

        # If we're just displaying a selection, finish here
        if not args.pick:
            break

        print(
            '\nChoose a game to create a new active session for. Input 0 to pass on all games. -1 to push timer without passing (i.e. too expensive). Q to abort.'
        )
        selection = input("Selection: ")

        if selection == 'q' or selection == 'Q':
            break

        selection = int(selection)

        if selection == 0:
            # Increment the pass counter on each game
            for game in games:
                # Don't propose game again
                passed_ids.append(game['id'])

                # If eternal still undecided
                # give option to make eternal
                if game['eternal'] is None:
                    eternal = input(
                        'Should this game never stop being proposed? Y/N/P[ass]: '
                    )
                    if eternal == 'Y' or eternal == 'y':
                        db.set_eternal(conn, game['id'], 1)
                    elif eternal == 'N' or eternal == 'n':
                        db.set_eternal(conn, game['id'], 0)

                # If the game is not out yet, don't increment
                if game['release_year'] != None and game[
                        'release_year'] != '' and int(
                            game['release_year']) == date.today().year:
                    freebie = input(
                        '%s was released this year. Has it been released? Y/N: '
                        % game['title'])
                    if freebie == 'N' or freebie == 'n':
                        continue
                new_passes = db.inc_pass(conn, game['id'])

                # Delay next possible proposal according to passes
                if new_passes == 1:
                    db.set_next_valid_date(
                        conn, game['id'],
                        date.today() + datetime.timedelta(days=30))
                elif new_passes == 2:
                    db.set_next_valid_date(
                        conn, game['id'],
                        date.today() + datetime.timedelta(days=90))
                else:
                    db.set_next_valid_date(
                        conn, game['id'],
                        date.today() + datetime.timedelta(days=180))

        elif selection == -1:
            for game in games:
                db.set_next_valid_date(
                    conn, game['id'],
                    date.today() + datetime.timedelta(days=90))

            continue
        else:
            # Create an active session
            game = games[selection - 1]
            db.create_session(conn, game['id'])
            print('Created a new session of %s.' % game['title'])
            break

        print('\n')

    # So scared of commitment
    db.dump_csvs(conn, path)