Some code in spline-pokedex orders by `id`, which has worse consequences
than it may seem (e.g. instead of defaulting to most recent games, the
comparifier defaults to XD). This is the first step to fixing that.
I actually reripped all the D/P data, too, and compared them myself just
to be sure, but those four were all there was. (The other move from the
last commit was Poison Gas—we had its old accuracy right, remember.)
etree and AtomicString will be moved in python-markdown 2.1
See commit https://github.com/waylan/Python-Markdown/commit/89a4f3d0829a7 :
Cleaned up markdown namespace. This may be a backward incompatible
change for some extensions. They should be importing from
markdown.util
No reason to instantiate every time as_html's called, is there?
Also, sessions use a markdown_extension attribute instead of
markdown_extension_class. The latter is only used to set the former when
the session is created (unless another markdown_extension_class is given,
of course).
Links such as []{pokemon:mewthree} can come from users, so they should not
crash the parser.
So, when an object is not found (or more than one is found), call
identifier_url() directly, instead of failing to get the object for
object_url(). Essentially, treat the link as having an unknown category
(like mechanic:, currently).
The test that check the pokédex descriptions updated so that only
links to known objects and "mechanic:" are allowed.
Linked-to objects aren't required to have identifiers now, so object_url()
in custom extensions might need to be changed.
The one in the test did, for example.
Now results are sorted by is-this-your-language (times levenshtein
distance, if appropriate), then by rough class of result (Pokémon, then
moves, then abilities, etc.) and finally by name.
This fixes a couple issues:
- If both a foreign name and a local name matched a wildcard lookup,
you'll see the local name. Before, you'd see whichever happened to be
first alphabetically.
- Wildcard results are more likely to have useful stuff at the top,
rather than being dominated by foreign junk and names of obscure
locations.
This also updates our usage of the whoosh API, which was old and busted
as of 2.0 or so.
Language identifiers are stored and retrieved, rather than English
names.
Language weighting biases towards the current language, rather than to
English.
Language is no longer considered nullable to indicate English.
Duplicate names in other languages are no longer omitted from the index.
Previously, every single spline-pokedex request tacked another markdown
extension onto a global list in spline, making markdown processing just
a little bit slower over time. This is terrible.
Now we do something a little less crazy and a little more global. Wait,
is that less crazy or more?
All accessors now take a `root` arg, the root of the media tree.
Alternatively `root` can be a custom MediaFile subclass, which should allow
neat tricks like:
- Checking some kind of manifest to prevent stat() calls
- Custom properties of the file objects (e.g. for HTML <img> tags)
- Downloading the media on demand
Tests assume media is at pokedex/data/media, skip otherwise.
- the Session has a `pokedex_link_maker` property, whose `object_url`
method is used to make URLs in Markdown
- pokemon.names_table.name is now an ordinary Unicode column
- pokemon.name is a MarkdownString that is aware of the session and the
language the string is in
- pokemon.name_map is a dict-like association_proxy of the above
- move.effect works similarly, with transparent $effect_chance substitution
as before
- as_text() is now a function that takes the session as an argument
- likewise as_html(), which also takes URL makers and the language
- since there should be only one link extension, it is registered by
setting default_link_extension, not appending to markdown_extensions.
This only affects the __html__ attribute.
Sometimes, translations are incomplete. Handle this gracefully by allowing
fallback languages. If there are none, fall back to the identifier to get
at least some order.
A few tests of the accessors, along with a very dumb, long-running script
to ensure everything is in its proper place, and there's nothing but the
proper things.
For now it still finds some beta form cruft for Burmy, Pichu and Cherrim.
(Translations cannot be dumped properly because the source string hash
isn't in the database.)
By default, unofficial texts are only dumped for English, but that can
be configured if someone wants CSVs for different language(s).
Official texts (<thing>_names rows for official languages) are always
dumped.
There are now (well, have been for a while) multiple ways to evolve
a Pokémon from its unique parent, so the current schema wasn't working.
The parent Pokémon has moved back to the main pokemon table, and
pokemon_evolution has grown an artificial primary key.
New evolution methods for Milotic, Leafeon, Glaceon, Magnezone, and
Probopass have been added.
English and Japanese. Woo!
The text dump contained a bunch of duplicate location names (possibly
for the Entralink?). I've merged them in the locations table, but
location_game_indices still has the duplicates—that is, a location can
now have multiple game_index values in one generation (necessitating a
small schema change).
As per http://bugs.veekun.com/projects/pokedex/wiki/Identifiers?version=3.
- The following tables were handled in commit "2090e34 Move English
texts to language-specific tables": berry_firmness, item_categories,
move_battle_styles, move_damage_classes, move_effect_categories,
pokeathlon_stats, pokemon_colors, pokemon_habitats, regions, types,
versions.
- These tables are skipped, pending further discussion:
generations, growth_rates, move_targets, stats.
- Deviations from the wiki:
- egg_groups: 'no-eggs' is not changed to 'noeggs'
- encounter_terrains: the 'old-rod' alternative is used.
- types: 'unknown' is not changed to '???'
- pokemon_move_methods:
- 'level-up' is not changed to 'level'
- 'colosseum-purification' and 'xd-purification' are left alone,
because colosseum and xd have not yet been added as versions.
- 'xd-shadow' is left alone for consistency with 'xd-purificaiton'.
Importing pokedex can take several seconds due to its rather large
dependencies—in particular, sqlalchemy, whoosh, and pkg_resources seem
to be the largest offenders. Normally, it would be possible to import
only the submodules one needs (pokedex.db, say), but pokedex.__init__
brings in all the submodules, for use by the command-line interface.
The fix is rather obvious:
- Move the command-line stuff into pokedex.main.
Note: because the submodules are no longer imported by default, any
script which expects `import pokedex` to be useful will likely break.
Note: the `pokedex` command will not work until you re-run `python
setup.py develop`, to update entry_points.txt.
- Don't import pkg_resources until necessary.