Commit graph

90 commits

Author SHA1 Message Date
Damien Elmes
c415c437de check bs version 2012-04-22 04:51:09 +09:00
Damien Elmes
0317e63cfb remove init docstring; documented in addons.html now 2012-03-28 06:55:23 +09:00
Damien Elmes
f73cbcef51 check httplib2 version 2012-03-13 22:15:44 +09:00
Damien Elmes
0a677fee56 sync tweaks 2011-12-13 10:44:50 +09:00
Damien Elmes
35a10744a6 'open' was a silly choice 2011-12-12 02:25:16 +09:00
Damien Elmes
b99dbb1466 don't .reset() on deck load by default anymore 2011-12-05 13:40:37 +09:00
Damien Elmes
ddd890ee75 more fixes for schema being accidentally modified on model add 2011-11-27 13:50:49 +09:00
Damien Elmes
279a942642 deck -> collection 2011-11-23 17:47:44 +09:00
Damien Elmes
6e4e8249fb facts -> notes 2011-11-23 12:37:21 +09:00
Damien Elmes
6a93e69fee prevent people from shooting themselves in the foot 2011-04-28 09:31:48 +09:00
Damien Elmes
786600ebb6 check python version and locale on load 2011-04-28 09:24:03 +09:00
Damien Elmes
2dfdfad6f2 update license link 2011-04-28 09:24:01 +09:00
Damien Elmes
8fcc6b3085 gpl3->agpl 2011-04-28 09:24:01 +09:00
Damien Elmes
b2f74b2591 minor tweaks to doc 2011-04-28 09:23:55 +09:00
Damien Elmes
2f27133705 drop sqlalchemy; massive refactor
SQLAlchemy is a great tool, but it wasn't a great fit for Anki:
- We often had to drop down to raw SQL for performance reasons.
- The DB cursors and results were wrapped, which incurred a
  sizable performance hit due to introspection. Operations like fetching 50k
  records from a hot cache were taking more than twice as long to complete.
- We take advantage of sqlite-specific features, so SQL language abstraction
  is useless to us.
- The anki schema is quite small, so manually saving and loading objects is
  not a big burden.

In the process of porting to DBAPI, I've refactored the database schema:
- App configuration data that we don't need in joins or bulk updates has been
  moved into JSON objects. This simplifies serializing, and means we won't
  need DB schema changes to store extra options in the future. This change
  obsoletes the deckVars table.
- Renamed tables:
-- fieldModels -> fields
-- cardModels -> templates
-- fields -> fdata
- a number of attribute names have been shortened

Classes like Card, Fact & Model remain. They maintain a reference to the deck.
To write their state to the DB, call .flush().

Objects no longer have their modification time manually updated. Instead, the
modification time is updated when they are flushed. This also applies to the
deck.

Decks will now save on close, because various operations that were done at
deck load will be moved into deck close instead. Operations like undoing
buried card are cheap on a hot cache, but expensive on startup.
Programmatically you can call .close(save=False) to avoid a save and a
modification bump. This will be useful for generating due counts.

Because of the new saving behaviour, the save and save as options will be
removed from the GUI in the future.

The q/a cache and field cache generating has been centralized. Facts will
automatically rebuild the cache on flush; models can do so with
model.updateCache().

Media handling has also been reworked. It has moved into a MediaRegistry
object, which the deck holds. Refcounting has been dropped - it meant we had
to compare old and new value every time facts or models were changed, and
existed for the sole purpose of not showing errors on a missing media
download. Instead we just media.registerText(q+a) when it's updated. The
download function will be expanded to ask the user if they want to continue
after a certain number of files have failed to download, which should be an
adequate alternative. And we now add the file into the media DB when it's
copied to th emedia directory, not when the card is commited. This fixes
duplicates a user would get if they added the same media to a card twice
without adding the card.

The old DeckStorage object had its upgrade code split in a previous commit;
the opening and upgrading code has been merged back together, and put in a
separate storage.py file. The correct way to open a deck now is import anki; d
= anki.Deck(path).

deck.getCard() -> deck.sched.getCard()
same with answerCard
deck.getCard(id) returns a Card object now.

And the DB wrapper has had a few changes:
- sql statements are a more standard DBAPI:
 - statement() -> execute()
 - statements() -> executemany()
- called like execute(sql, 1, 2, 3) or execute(sql, a=1, b=2, c=3)
- column0 -> list
2011-04-28 09:23:53 +09:00
Damien Elmes
8cbd3c9f3b change deck loading call 2011-04-28 09:23:28 +09:00
Damien Elmes
9421a037f6 remove self explanatory module docstrings; strip trailing whitespace 2011-04-28 09:21:07 +09:00
Damien Elmes
f78abf2c34 bump version 2011-03-28 16:38:42 +09:00
Damien Elmes
5e23e168c0 bump version 2011-02-20 14:08:35 +09:00
Damien Elmes
1b027af439 bump version 2011-02-03 00:22:03 +09:00
Damien Elmes
eb0bb89f44 bump version 2011-01-27 08:13:10 +09:00
Damien Elmes
7a56e26be6 bump version 2011-01-22 07:36:10 +09:00
Damien Elmes
d57a371ca5 bump version 2011-01-18 04:33:16 +09:00
Damien Elmes
ab5c1621e3 bump version 2011-01-14 02:54:53 +09:00
Damien Elmes
5c0421b6e0 bump version 2011-01-13 05:54:41 +09:00
Damien Elmes
175f3f0a0e bump version 2011-01-12 16:31:02 +09:00
Damien Elmes
c534362071 bump version 2011-01-10 19:02:33 +09:00
Damien Elmes
82231a71b2 bump version 2011-01-07 21:43:13 +09:00
Damien Elmes
2e2d93649e bump version 2011-01-06 14:24:30 +09:00
Damien Elmes
33cbbdc368 bump version number 2011-01-03 13:46:27 +09:00
Damien Elmes
545c2cddcd bump version 2011-01-02 19:25:27 +09:00
Damien Elmes
6f10c588f6 bump version number 2010-12-27 03:01:39 +09:00
Damien Elmes
93a67931da bump version number 2010-12-25 12:49:31 +09:00
Damien Elmes
afa34d9d39 bump version 2010-12-21 01:45:17 +09:00
Damien Elmes
1b219679b6 bump version 2010-12-17 01:48:01 +09:00
Damien Elmes
d2e3d7932d bump version 2010-12-15 03:53:02 +09:00
Damien Elmes
154bf0cef4 bump version 2010-12-13 04:09:55 +09:00
Damien Elmes
98597dd56d bump version 2010-12-11 22:01:07 +09:00
Damien Elmes
9f276e3163 bump version 2010-12-11 02:33:25 +09:00
Damien Elmes
0c9672e7b8 rewrite media support
- media is no longer hashed, and instead stored in the db using its original
  name
- when adding media, its checksum is calculated and used to look for
  duplicates
- duplicate filenames will result in a number tacked on the file
- the size column is used to count card references to media. If media is
  referenced in a fact but not the question or answer, the count will be zero.
- there is no guarantee media will be listed in the media db if it is unused
  on the question & answer
- if rebuildMediaDir(delete=True), then entries with zero references are
  deleted, along with any unused files in the media dir.
- rebuildMediaDir() will update the internal checksums, and set the checksum
  to "" if a file can't be found
- rebuildMediaDir() is a lot less destructive now, and will leave alone
  directories it finds in the media folder (but not look in them either)
- rebuildMediaDir() returns more information about the state of media now
- the online and mobile clients will need to to make sure that when
  downloading media, entries with no checksum are non-fatal and should not
  abort the download process.
- the ref count is updated every time the q/a is updated - so the db should be
  up to date after every add/edit/import
- since we look for media on the q/a now, card templates like '<img
  src="{{{field}}}">' will work now
- export original files as gone as it is not needed anymore
- move from per-model media URL to deckVar. downloadMissingMedia() uses this
  now. Deck subscriptions will have to be updated to share media another way.
- pass deck in formatQA, as latex support is going to change
2010-12-11 01:19:31 +09:00
Damien Elmes
75da977026 bump version 2010-12-09 18:01:16 +09:00
Damien Elmes
878c9abb83 bump version 2010-12-07 18:04:53 +09:00
Damien Elmes
a23098c92c bump version 2010-12-02 09:55:06 +09:00
Damien Elmes
2352502807 bump version 2010-11-30 03:35:45 +09:00
Damien Elmes
74a0998a36 bump version 2010-11-28 18:21:00 +09:00
Damien Elmes
689a744266 bump version 2010-11-28 02:32:59 +09:00
Damien Elmes
e58d7f8dac bump version 2010-11-26 04:20:40 +09:00
Damien Elmes
37e269ab81 bump version for coming development release 2010-11-21 12:58:14 +09:00
Damien Elmes
c916478868 bump version number 2010-08-19 13:42:19 +09:00
Damien Elmes
ff60f105d9 add extra minor version number to ensure betas get upgraded 2010-08-02 13:26:48 +09:00