Exemplo n.º 1
0
def dump(session, options):
    from ptcgdex import tcg_tables
    from pokedex.db import load as dex_load
    from ptcgdex import load as ptcg_load
    tables = options['<table-identifier>']
    if options['--all']:
        tables = [t.__tablename__ for t in all_tables(tcg_tables.tcg_classes)]
    elif not tables:
        csv_classes = [t for t in tcg_tables.tcg_classes
                if getattr(t, 'load_from_csv', False)]
        tables = [t.__tablename__ for t in all_tables(csv_classes)]

    dex_load.dump(session,
        directory=options['--ptcg-csv-dir'],
        tables=tables,
        verbose=options['--verbose'],
        langs=['en'])
Exemplo n.º 2
0
def dump(session, options):
    from ptcgdex import tcg_tables
    from pokedex.db import load as dex_load
    from ptcgdex import load as ptcg_load
    tables = options['<table-identifier>']
    if options['--all']:
        tables = [t.__tablename__ for t in all_tables(tcg_tables.tcg_classes)]
    elif not tables:
        csv_classes = [
            t for t in tcg_tables.tcg_classes
            if getattr(t, 'load_from_csv', False)
        ]
        tables = [t.__tablename__ for t in all_tables(csv_classes)]

    dex_load.dump(session,
                  directory=options['--ptcg-csv-dir'],
                  tables=tables,
                  verbose=options['--verbose'],
                  langs=['en'])
Exemplo n.º 3
0
                    elif form.is_default and form.pokemon.is_default:
                        game_index = 0
                    else:
                        raise AssertionError()
                else:
                    game_index = lst.index(form_ident)
            obj = tables.PokemonFormGeneration(form=form, generation=gen,
                    game_index=game_index)
            session.add(obj)

q = session.query(tables.PokemonFormGeneration)
for species in session.query(tables.PokemonSpecies).options(
        eagerload_all('forms', 'pokemon_form_generations')):
    if len(species.forms) > 1:
        print species.name
    for gen in generations:
        if len(species.forms) == 1:
            pfg = q.get((species.forms[0].id, gen.id))
            assert pfg is None or pfg.game_index == 0
            continue
        forms = [(q.get((f.id, gen.id)), f) for f in species.forms if q.get((f.id, gen.id))]
        forms = [(pfg.game_index, f) for pfg, f in forms if pfg]
        if forms:
            forms.sort()
            pl = ["%s=%s" % (gi, f.form_identifier) for gi, f in forms]
            print '   ', gen.id, ' '.join(pl)

load.dump(session, tables=['pokemon_form_generations'])
print "Dumped to CSV, rolling back transaction"
session.rollback()
"""


from sqlalchemy.sql import exists, func
from sqlalchemy.orm import lazyload
from sqlalchemy import and_, or_, not_

from pokedex.db import connect, tables, load

session = connect()

session.query(tables.VersionGroupPokemonMoveMethod).delete()

q = session.query(tables.VersionGroup, tables.PokemonMoveMethod)
q = q.filter(exists().where(and_(
        tables.PokemonMove.pokemon_move_method_id == tables.PokemonMoveMethod.id,
        tables.PokemonMove.version_group_id == tables.VersionGroup.id)))
q = q.options(lazyload('*'))
for version_group, pokemon_move_method in q:
    entry = tables.VersionGroupPokemonMoveMethod(
            version_group=version_group,
            pokemon_move_method=pokemon_move_method,
        )
    session.add(entry)


load.dump(session, tables=['version_group_pokemon_move_methods'])
print("Dumped to CSV, rolling back transaction")
session.rollback()
Exemplo n.º 5
0
                    else:
                        raise AssertionError()
                else:
                    game_index = lst.index(form_ident)
            obj = tables.PokemonFormGeneration(form=form,
                                               generation=gen,
                                               game_index=game_index)
            session.add(obj)

q = session.query(tables.PokemonFormGeneration)
for species in session.query(tables.PokemonSpecies).options(
        eagerload_all('forms', 'pokemon_form_generations')):
    if len(species.forms) > 1:
        print species.name
    for gen in generations:
        if len(species.forms) == 1:
            pfg = q.get((species.forms[0].id, gen.id))
            assert pfg is None or pfg.game_index == 0
            continue
        forms = [(q.get((f.id, gen.id)), f) for f in species.forms
                 if q.get((f.id, gen.id))]
        forms = [(pfg.game_index, f) for pfg, f in forms if pfg]
        if forms:
            forms.sort()
            pl = ["%s=%s" % (gi, f.form_identifier) for gi, f in forms]
            print '   ', gen.id, ' '.join(pl)

load.dump(session, tables=['pokemon_form_generations'])
print "Dumped to CSV, rolling back transaction"
session.rollback()
"""

from sqlalchemy.sql import exists, func
from sqlalchemy.orm import lazyload
from sqlalchemy import and_, or_, not_

from pokedex.db import connect, tables, load

session = connect()

session.query(tables.VersionGroupPokemonMoveMethod).delete()

q = session.query(tables.VersionGroup, tables.PokemonMoveMethod)
q = q.filter(exists().where(
    and_(
        tables.PokemonMove.pokemon_move_method_id ==
        tables.PokemonMoveMethod.id,
        tables.PokemonMove.version_group_id == tables.VersionGroup.id)))
q = q.options(lazyload('*'))
for version_group, pokemon_move_method in q:
    entry = tables.VersionGroupPokemonMoveMethod(
        version_group=version_group,
        pokemon_move_method=pokemon_move_method,
    )
    session.add(entry)

load.dump(session, tables=['version_group_pokemon_move_methods'])
print "Dumped to CSV, rolling back transaction"
session.rollback()