1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Addressed all of pyflakes3's complaints

This commit is contained in:
John T. Wodder II 2016-11-24 21:29:58 +00:00
parent 82335886e1
commit c3f566b2c9
16 changed files with 42 additions and 46 deletions

View file

@ -4,7 +4,7 @@ import re
from sqlalchemy import engine_from_config, orm
from ..defaults import get_default_db_uri
from .tables import Language, metadata
from .tables import metadata
from .multilang import MultilangSession, MultilangScopedSession
ENGLISH_ID = 9
@ -46,7 +46,7 @@ def connect(uri=None, session_args={}, engine_args={}, engine_prefix=''):
### Connect
engine_args[engine_prefix + 'url'] = uri
engine = engine_from_config(engine_args, prefix=engine_prefix)
conn = engine.connect()
engine.connect()
metadata.bind = engine
all_session_args = dict(autoflush=True, autocommit=False, bind=engine)

View file

@ -3,7 +3,6 @@ from __future__ import print_function
import csv
import fnmatch
import io
import os.path
import sys
@ -12,7 +11,7 @@ import sqlalchemy.sql.util
import sqlalchemy.types
import pokedex
from pokedex.db import metadata, tables, translations
from pokedex.db import metadata, translations
from pokedex.defaults import get_default_csv_dir
from pokedex.db.dependencies import find_dependent_tables
from pokedex.db.oracle import rewrite_long_table_names
@ -323,7 +322,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
# Could happen if row A refers to B which refers to C.
# This is ridiculous and doesn't happen in my data so far
raise ValueError("Too many levels of self-reference! "
"Row was: " + str(row))
"Row was: " + str(row_data))
session.execute(
insert_stmt.values(**row_data)

View file

@ -174,7 +174,7 @@ class PokedexLinkPattern(markdown.inlinepatterns.Pattern):
self.game_language = game_language
def handleMatch(self, m):
from pokedex.db import tables, util
from pokedex.db import tables
start, label, category, target, end = m.groups()
try:
table = dict(

View file

@ -1,7 +1,5 @@
from functools import partial
from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy
from sqlalchemy.orm import Query, aliased, mapper, relationship, synonym
from sqlalchemy.orm import Query, mapper, relationship, synonym
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.orm.scoping import ScopedSession
from sqlalchemy.orm.session import Session, object_session

View file

@ -26,18 +26,15 @@ classes in that module can be used to change the default language.
"""
# XXX: Check if "gametext" is set correctly everywhere
import collections
from functools import partial
import six
from sqlalchemy import Column, ForeignKey, MetaData, PrimaryKeyConstraint, Table, UniqueConstraint
from sqlalchemy import Column, ForeignKey, MetaData, PrimaryKeyConstraint, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import backref, relationship
from sqlalchemy.orm.session import Session
from sqlalchemy.orm.interfaces import AttributeExtension
from sqlalchemy.sql import and_, or_
from sqlalchemy.schema import ColumnDefault
from sqlalchemy.sql import and_
from sqlalchemy.types import Boolean, Enum, Integer, SmallInteger, Unicode, UnicodeText
from pokedex.db import markdown, multilang
@ -56,7 +53,7 @@ class TableSuperclass(object):
if not pk_constraint:
return u"<%s object at %x>" % (typename, id(self))
pk = u', '.join(unicode(getattr(self, column.name))
pk = u', '.join(six.text_type(getattr(self, column.name))
for column in pk_constraint.columns)
try:
return u"<%s object (%s): %s>" % (typename, pk, self.identifier)
@ -64,10 +61,13 @@ class TableSuperclass(object):
return u"<%s object (%s)>" % (typename, pk)
def __str__(self):
return unicode(self).encode('utf8')
if six.PY2:
return six.text_type(self).encode('utf8')
else:
return type(self).__unicode__(self)
def __repr__(self):
return unicode(self).encode('utf8')
return str(self)
mapped_classes = []
class TableMetaclass(DeclarativeMeta):

View file

@ -30,6 +30,7 @@ import os
import re
from collections import defaultdict
import six
from six.moves import zip
from pokedex.db import tables
@ -155,10 +156,13 @@ class Message(object):
return template.format(self=self, string=string)
def __str__(self):
return unicode(self).encode('utf-8')
if six.PY2:
return six.text_type(self).encode('utf8')
else:
return type(self).__unicode__(self)
def __repr__(self):
return unicode(self).encode('utf-8')
return str(self)
class Translations(object):
"""Data and opertaions specific to a location on disk (and a source language)
@ -648,7 +652,6 @@ def match_to_source(source, *translations):
if first or match:
best_string = current_string
best_crc = current_crc
best_message = translation
if match:
break
first = False

View file

@ -9,8 +9,6 @@ from sqlalchemy.sql.expression import func
from sqlalchemy.sql.functions import coalesce
from sqlalchemy.orm.exc import NoResultFound
from pokedex.db import tables
### Getter
def get(session, table, identifier=None, name=None, id=None, language=None):