Commit Graph

25 Commits

Author SHA1 Message Date
RumovZ
ab7c07e830 Use fields_check() instead of duplicate_or_empty() 2021-06-12 17:34:46 +02:00
Damien Elmes
948fc5f777 add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
Damien Elmes
b7587cb8d2 update TR references that contain arguments 2021-03-26 14:21:04 +10:00
Damien Elmes
48354931da update some no-arg TR constants 2021-03-26 12:37:18 +10:00
Damien Elmes
ce243c2cae Simplify note adding and the deck/notetype choosers
The existing code was really difficult to reason about:

- The default notetype depended on the selected deck, and vice versa,
and this logic was buried in the deck and notetype choosing screens,
and models.py.
- Changes to the notetype were not passed back directly, but were fired
via a hook, which changed any screen in the app that had a notetype
selector.

It also wasn't great for performance, as the most recent deck and tags
were embedded in the notetype, which can be expensive to save and sync
for large notetypes.

To address these points:

- The current deck for a notetype, and notetype for a deck, are now
stored in separate config variables, instead of directly in the deck
or notetype. These are cheap to read and write, and we'll be able to
sync them individually in the future once config syncing is updated in
the future. I seem to recall some users not wanting the tag saving
behaviour, so I've dropped that for now, but if people end up missing
it, it would be simple to add as an extra auxiliary config variable.
- The logic for getting the starting deck and notetype has been moved
into the backend. It should be the same as the older Python code, with
one exception: when "change deck depending on notetype" is enabled in
the preferences, it will start with the current notetype ("curModel"),
instead of first trying to get a deck-specific notetype.
- ModelChooser has been duplicated into notetypechooser.py, and it
has been updated to solely be concerned with keeping track of a selected
notetype - it no longer alters global state.
2021-03-10 11:53:27 +10:00
Damien Elmes
bec77fd420 undo support for bulk tag add/remove 2021-03-10 11:47:53 +10:00
Damien Elmes
9d853bbb03 start work on more clearly defining backend/protobuf boundaries
- anki._backend stores the protobuf files and rsbackend.py code
- pylib modules import protobuf messages directly from the
_pb2 files, and explicitly export any will be returned or consumed
by public pylib functions, so that calling code can import from pylib
- the "rsbackend" no longer imports and re-exports protobuf messages
- pylib can just consume them directly.
- move errors to errors.py

Still todo:

- rsbridge
- finishing the work on rsbackend, and check what we need to add
back to the original file location to avoid breaking add-ons
2021-01-31 18:55:45 +10:00
Arthur Milchior
2c73dcb2e5 d->col in tests
obtained by
```
sed -i "s/\bd\b/col/g" pylib/tests/*py qt/tests/*py
```
2020-07-17 06:58:32 +02:00
Arthur Milchior
c376714a9b deck->col in tests
Obtained by
```
sed -i "s/\bdeck\b/col/g" pylib/tests/*py qt/tests/*py
```
2020-07-17 06:50:46 +02:00
Arthur Milchior
425b82e6e7 f2->note2 in test
Obtained by
```
sed -i "s/\bf2\b/note2/g" pylib/tests/*py qt/tests/*py
```
2020-07-17 06:47:44 +02:00
Arthur Milchior
4c25835d27 f->note in test
Obtained by sed -i "s/\bf\b/note/g" pylib/tests/*py qt/tests/*py
2020-07-17 06:47:44 +02:00
Damien Elmes
2ac33500eb fetch stock notetypes from backend 2020-05-15 17:08:24 +10:00
Damien Elmes
a2b7a30841 fetch/set remaining collection properties as required 2020-05-15 13:33:37 +10:00
Damien Elmes
f637ac957d hook up new note and note type handling
- notetypes are fetched from the DB as needed, and cached in Python
- handle note type changes in the backend. Multiple operations can now
be performed in one go, but this is not currently exposed in the GUI.
- extra methods to grab sorted note type names quickly, and fetch by
name
- col.models.save() without a provided notetype is now a no-op
- note loading/saving handled in the backend
- notes with no valid cards can now be added
- templates can now be deleted even if they would previously
orphan notes

a number of fixmes have been left in notes.py and models.py
2020-05-12 21:13:33 +10:00
Damien Elmes
e005140909 hide warning when running tests 2020-04-06 20:24:05 +10:00
Damien Elmes
8efc09d4ef emulate named args 2020-04-06 20:09:44 +10:00
Damien Elmes
4d917cc65b add self.col.tr() shortcut 2020-02-27 12:33:15 +10:00
Damien Elmes
0c49431719 FString -> TR 2020-02-27 12:25:19 +10:00
Damien Elmes
4430c67069 rework Fluent handling
- all .ftl files for a language are concatenated into a single file
at build time
- all languages are included in the binary
- external ftl files placed in the ftl folder can override the
built-in definitions
- constants are automatically generated for each string key
- dropped the separate StringsGroup enum
2020-02-23 13:22:50 +10:00
Damien Elmes
232a8625bf move answer button labels into fluent 2020-02-21 15:29:38 +10:00
Damien Elmes
6e3f1d2e26 Revert "test out the Python Fluent implementation"
This reverts commit 181c17a0988cf9e57b2604746000c6072cb96206.

Reverting this to keep as a record.
2020-02-17 08:40:17 +10:00
Damien Elmes
8abb35372a test out the Python Fluent implementation
The parsing step is considerably slower in Python, but if parsing
is moved out of the test function, Python wins at 45ms to Rust's 67ms
on 10,000 rounds, presumably due to the overhead of serializing to
Protobuf. Not enough of a difference to justify the inclusion of extra
dependencies and duplicating the lookup code in any case.
2020-02-17 08:40:17 +10:00
Damien Elmes
c395003def expose translations to Python 2020-02-17 08:40:17 +10:00
Damien Elmes
17ebdfc099 extract and flag AV tags as part of the render process
We can now show replay buttons for the audio contained in {{FrontSide}}
without having to play it again when the answer is shown.

The template code now always defers FrontSide rendering, as it wasn't
a big saving, and meant the logic had to be implemented twice.
2020-01-24 11:06:11 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00