Commit graph

26 commits

Author SHA1 Message Date
Yoshi
2fe067bd32 Stop using deprecated distro.linux_distribution() (#1421) 2021-10-12 17:00:47 +10:00
Damien Elmes
3c1729e91b run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
Damien Elmes
98ff2102b7 apply some f-string updates via flynt 2021-10-02 23:52:02 +10:00
Damien Elmes
9025985505 replace the old stripHTML() methods with the backend implementation
Python's regex engine performs pathologically on regexes like
'<!--.*?-->' when fed a large string of repeating '<!--' clauses.
Thanks to JaimeSlome / security@huntr.dev for the report; closes #1380.

Solved by switching to the Rust implementation, which does not suffer
from this issue.

entsToText(), minimizeHTML(), and the old regex constants have been
removed; they do not appear to be used by any add-ons.
2021-10-01 23:15:45 +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
RumovZ
2aa16eadce Fix typo 2021-06-13 08:59:58 +02:00
Damien Elmes
8c1a386202 Revert "ensure fields normalized before checksumming"
This reverts commit f4bd867b3b54b172125d2f2021c8c6a6e69c4c4d.
2021-03-17 22:21:13 +10:00
Damien Elmes
455a93cc27 ensure fields normalized before checksumming
https://forums.ankiweb.net/t/python-checksum-rust-checksum/8195
2021-03-13 10:23:32 +10:00
RumovZ
7d4f830322 Annotate decks.rem as deprecated 2021-03-11 11:26:35 +01:00
Damien Elmes
92bdc90b44 convert some pylib strings to f-strings with flynt
excluded some changes where readability got noticeably worse
2021-02-11 09:51:09 +10:00
Damien Elmes
bf7528d90a minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
0fee5b5bfd warn add-ons importing json from anki.utils; use stdout not stderr 2021-01-31 21:05:46 +10:00
Damien Elmes
37ffa66736 add some typehints, and remove some unused code 2021-01-31 20:56:21 +10:00
Damien Elmes
a6be0f493b 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
Damien Elmes
aeca369c9b update to latest isort, pylint and pytest 2020-08-31 12:05:36 +10:00
Damien Elmes
923d85f66b clone db.py into dbproxy.py 2020-03-20 21:15:23 +10:00
Damien Elmes
70ae99778f remove old fmtTimeSpan() and associated strings 2020-02-23 18:47:16 +10:00
Damien Elmes
74bff450e2 add non-abbreviated timespan translation; update existing short=True calls
- drop the '5m3s' special casing done in the card stats screen, and
just use decimals
- change alignment of the review log so that the non-abbreviated
spans are easier to read
2020-02-21 15:29:38 +10:00
Damien Elmes
11647daec1 move answer_button_time to the backend, split sched into separate module 2020-02-21 15:29:38 +10:00
Damien Elmes
2633d6db4b move answer button labels into fluent 2020-02-21 15:29:38 +10:00
Damien Elmes
58cbca9a8c inject legacy funcs referencing aqt in GUI load 2020-01-23 18:20:19 +10:00
Damien Elmes
00a0c539a3 fix lint 2020-01-23 18:12:57 +10:00
Damien Elmes
35435a130e basic night mode support
Forces the Fusion theme when running night mode, so we don't need
to work around platform themes that don't respond to the defined
palette.

Feedback/suggestions on the chosen colours welcome - _vars.scss is the
file to change if you want to experiment with adjustments.
2020-01-23 17:27:07 +10:00
Damien Elmes
5646ee642a automatically disable add-ons that have been marked as incompatible 2020-01-19 13:37:55 +10:00
Damien Elmes
a113887d56 add buildhash to rspy and aqt, and check all three modules match 2020-01-03 15:15:18 +10:00
Damien Elmes
2a00e0a6b0 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00
Renamed from lib-python/anki/utils.py (Browse further)