Commit graph

1023 commits

Author SHA1 Message Date
Damien Elmes
2238cdaa43 rename Config in protobuf to avoid conflict with module name
+ use the enum directly, instead of wrapping it in an object

Python code retains the old "Config" name.
2021-07-11 19:27:08 +10:00
Damien Elmes
e86e0a64ea move proto files into separate py_library in same namespace
Will allow importing the Protobuf without pulling in the rest of
the library. This is not a full PEP420 namespace, and the wheel still
bundles everything - it just makes things easier in a Bazel workspace.
I originally tried with PEP420, but it required more invasive changes,
and I ran into issues with mypy.
2021-07-11 14:51:25 +10:00
Damien Elmes
f0ce1cfc9d rename workspace
I'd forgotten that Bazel "helpfully" adds __init__.py files into folders
that match the workspace name, breaking imports.
2021-07-10 23:58:53 +10:00
Damien Elmes
e3b53fc078 split out remaining tags, stats, media and rendering 2021-07-10 23:16:18 +10:00
Damien Elmes
673955de5b split out sync, search, scheduler & config 2021-07-10 21:33:12 +10:00
Damien Elmes
1fb86d499d split out decks, deckconfig, notes, notetypes 2021-07-10 20:44:22 +10:00
Damien Elmes
c43674762e split out cards and collection 2021-07-10 19:52:31 +10:00
Damien Elmes
5255409093 refactor protobuf handling for split/import
In order to split backend.proto into a more manageable size, the protobuf
handling needed to be updated. This took more time than I would have
liked, as each language handles protobuf differently:

- The Python Protobuf code ignores "package" directives, and relies
solely on how the files are laid out on disk. While it would have been
nice to keep the generated files in a private subpackage, Protobuf gets
confused if the files are located in a location that does not match
their original .proto layout, so the old approach of storing them in
_backend/ will not work. They now clutter up pylib/anki instead. I'm
rather annoyed by that, but alternatives seem to be having to add an extra
level to the Protobuf path, making the other languages suffer, or trying
to hack around the issue by munging sys.modules.
- Protobufjs fails to expose packages if they don't start with a capital
letter, despite the fact that lowercase packages are the norm in most
languages :-( This required a patch to fix.
- Rust was the easiest, as Prost is relatively straightforward compared
to Google's tools.

The Protobuf files are now stored in /proto/anki, with a separate package
for each file. I've split backend.proto into a few files as a test, but
the majority of that work is still to come.

The Python Protobuf building is a bit of a hack at the moment, hard-coding
"proto" as the top level folder, but it seems to get the job done for now.

Also changed the workspace name, as there seems to be a number of Bazel
repos moving away from the more awkward reverse DNS naming style.
2021-07-10 19:17:05 +10:00
Damien Elmes
14263c7a79 move protobuf into separate folder in preparation for multiple files 2021-07-09 21:02:40 +10:00
Damien Elmes
2a6040170a fixed inability to import v1 into v1
https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/116
2021-07-08 10:32:44 +10:00
Damien Elmes
bfa8ee6b96 more friendly message for v2 import into v1 2021-07-08 10:32:27 +10:00
RumovZ
e763745e05 Add pylib/browser.py for literal config keys
Also, remove config bools for sort order.
2021-07-05 12:44:48 +02:00
Damien Elmes
b21af06d75 stop (un)escaping media filenames
Back in the WebKit days, images with Unicode filenames would fail to
appear if they weren't percent-escaped. This no longer seems to be the
case - with this patch, images appear correctly on the Mac and Windows
platforms I tested with.

Fixes https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/96
Fixes #1219
2021-07-04 15:27:29 +10:00
Damien Elmes
6c35806c16 add missing stringcase dep 2021-06-29 17:40:20 +10:00
Damien Elmes
f9560586cb PEP8 collection.py 2021-06-27 15:12:22 +10:00
Damien Elmes
fba156ec93 PEP8 models.py 2021-06-27 14:30:00 +10:00
Damien Elmes
3c46c9a7eb PEP8 decks.py 2021-06-27 14:02:48 +10:00
Damien Elmes
d6e3964151 PEP8 cards.py 2021-06-27 12:12:23 +10:00
Damien Elmes
cd80acce55 move+rename deprecated decorators to _legacy.py
+ take method instead of string, so we can ensure symbol exists
2021-06-26 15:50:19 +10:00
Damien Elmes
d73231dbdc PEP8 notes.py
An example of how we can start migrating the codebase to PEP8:

- enable invalid-name at the top
- use bazel run pylib:pylint to identify names that need renaming
- use PyCharm or similar to rename the functions/variables
- in the cases where the conversion is not just snake_case, use
.register_deprecated_aliases()

+ removed the __repr__() definition, it dumps all the note content
and obscures the error message
2021-06-26 11:38:59 +10:00
Damien Elmes
5e41eb7565 add a helper so we can get semi-automatic camelCase conversion 2021-06-26 11:33:35 +10:00
Damien Elmes
b912b2d145 enable some pylint convention tests in pylib 2021-06-26 10:11:05 +10:00
Damien Elmes
795afb7068 update most rust deps; skip rusqlite 2021-06-25 15:35:25 +10:00
Damien Elmes
f17a3ae010 fix importer mistakenly allowing import of v2 collection into v1
The instance variable is ugly, but should avoid breaking some monkey
patching done by Special Fields
2021-06-25 09:50:10 +10:00
Damien Elmes
d89c538c48 in/out -> request/response
The saved characters weren't worth the increased difficulty when
reading, and the fact that we were deviating from protobuf norms.
2021-06-20 15:49:20 +10:00
Damien Elmes
532ac8b511 Merge pull request #1230 from RumovZ/fields-check
Check for misplaced or missing clozes when adding and in the editor
2021-06-17 21:26:16 +10:00
Damien Elmes
3442ba36a9 fix 'set due date' not being remembered in browser
https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/19
2021-06-16 18:50:05 +10:00
Damien Elmes
521a158406 update to latest mypy
mypy's move to external types-* packages is a PITA, as it requires them
to be installed in site-packages, and provides no way to specify a custom
site-packages folder, necessitating extra scripts to mock the
site-packages path, and copy+rename the stub packages into a separate
folder.
2021-06-16 16:04:59 +10:00
Damien Elmes
51d0fc29a6 multiple assignment confuses mypy 2021-06-15 08:42:34 +02:00
RumovZ
2aa16eadce Fix typo 2021-06-13 08:59:58 +02:00
RumovZ
0e49e74080 Use fields_check() instead of duplicate_or_empty() 2021-06-12 17:34:46 +02:00
RumovZ
46ee710a06 Check for out-of-place/missing clozes when adding 2021-06-12 10:05:42 +02:00
RumovZ
4fb2299386 Add check for out-of-place/missing clozes 2021-06-12 10:02:21 +02:00
Damien Elmes
cd303de619 specific encoding of strings.json
https://forums.ankiweb.net/t/win10-build-error-unicodedecodeerror-gbk-codec-cant-decode-byte-0x91/10714
2021-06-11 20:12:38 +10:00
Damien Elmes
153e1e8d41 new change notetype implementation for the frontend
- changes can now be undone
- the same field can now be mapped to multiple target fields, allowing
fields to be cloned
- the old Qt dialog has been removed
- the old col.models.change() API calls the new code, to avoid
breaking existing consumers. It requires the field map to always
be passed in, but that appears to have been the common case.
- closes #1175
2021-06-10 22:19:24 +10:00
cherryblossom
462da55fd5 fix documentation links 2021-06-03 16:51:03 +10:00
Damien Elmes
b56616066b fix styling changes not updating preview
regression caused by 691a5c5c44
2021-06-02 15:13:34 +10:00
Damien Elmes
d38f57cf3c Merge pull request #1213 from RumovZ/new-flags
Add pink, turquoise and purple flags
2021-06-02 11:22:26 +10:00
Damien Elmes
512dfd59cd limit custom study to 100 tags
The hard limit from sqlite may be larger, but things slow down as more
tags are selected.

https://forums.ankiweb.net/t/unable-to-create-custom-test/10467

There are a number of things that could be improved here:

- we should show a live count so users are aware of the limit
- we should be filling in the parent tags when they're not explicitly
listed on a card
- we should reconsider disabling the 'tags to include' by default

It may make sense to defer these changes until we can move this screen
into Svelte/handle the processing in the backend.
2021-06-02 11:15:39 +10:00
RumovZ
9e56a4421b Add violet, turquoise and purple flags 2021-05-31 12:03:30 +02:00
Damien Elmes
0b6beaa1da remove deck protobuf from frontend
Like the previous change, avoid exposing the protobuf as a public API
for now. It requires more thought, and is probably better done with
either extra helper accessors like decks.name(), or via a native class.
2021-05-31 16:31:06 +10:00
Damien Elmes
2044ed7f31 remove deck config and notetype protobuf from frontend
Not yet used by anything yet, and we may want to use native classes
for these instead, like is done for Notes and Cards. Decks to follow.
2021-05-31 16:27:58 +10:00
Damien Elmes
3d0a3a5707 fix exporting of non-default deck configs 2021-05-31 16:27:58 +10:00
Damien Elmes
8730e98778 Merge pull request #1200 from RumovZ/template-checks
Template checks
2021-05-29 10:28:06 +10:00
RumovZ
b1dbebb1a6 Allow empty field name in templates 2021-05-28 11:37:05 +02:00
RumovZ
613320aca3 Adjusts tests to pass new template checks 2021-05-28 10:08:55 +02:00
Damien Elmes
b0bde454ff add v3 scheduler to prefs screen 2021-05-27 23:09:49 +10:00
Damien Elmes
b810ee4b3b next_states() didn't need to be public 2021-05-26 15:12:48 +10:00
Damien Elmes
52a98ce0ce change get_queued_cards() to no longer return congrats info 2021-05-26 12:59:45 +10:00
RumovZ
d4a163f893 Update tests to avoid duplicate front templates 2021-05-25 21:58:12 +02:00