This commit is contained in:
Stefan Kangas 2022-11-24 11:18:57 +01:00 committed by GitHub
parent fa9ab5ee3f
commit 5551a37f03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 44 additions and 43 deletions

View file

@ -106,6 +106,7 @@ Bart Louwers <bart.git@emeel.net>
Sam Penny <github.com/sam1penny> Sam Penny <github.com/sam1penny>
Yutsuten <mateus.etto@gmail.com> Yutsuten <mateus.etto@gmail.com>
Zoom <zoomrmc+git@gmail.com> Zoom <zoomrmc+git@gmail.com>
Stefan Kangas <stefankangas@gmail.com>
******************** ********************

View file

@ -95,7 +95,7 @@ about 6 gigabytes of temporary files. Once you've created the wheels, you can
remove the other files to free up space if you wish. remove the other files to free up space if you wish.
- `bazel clean --expunge` will remove the generated Bazel files, freeing up - `bazel clean --expunge` will remove the generated Bazel files, freeing up
most of the space. The files are usualy stored in a subdir of most of the space. The files are usually stored in a subdir of
`~/.cache/bazel` or `\bazel\anki` `~/.cache/bazel` or `\bazel\anki`
- `rm -rf ~/.cache/bazel*` or `\bazel\anki` will remove cached downloads as - `rm -rf ~/.cache/bazel*` or `\bazel\anki` will remove cached downloads as
well, requiring them to be redownloaded if you want to build again. well, requiring them to be redownloaded if you want to build again.

View file

@ -1,7 +1,7 @@
# Protocol Buffers # Protocol Buffers
Anki uses [different implementations of Protocol Buffers](./architecture.md#protobuf) Anki uses [different implementations of Protocol Buffers](./architecture.md#protobuf)
and each has its own pecularities. This document highlights some aspects relevant and each has its own peculiarities. This document highlights some aspects relevant
to Anki and hopefully helps to avoid some common pitfalls. to Anki and hopefully helps to avoid some common pitfalls.
For information about Protobuf's types and syntax, please see the official [language guide](https://developers.google.com/protocol-buffers/docs/proto3). For information about Protobuf's types and syntax, please see the official [language guide](https://developers.google.com/protocol-buffers/docs/proto3).
@ -83,8 +83,8 @@ when choosing _Downgrade_), does not make use of Protobuf messages.
### Field Numbers ### Field Numbers
Field numbers larger than 15 need an additional byte to encode, so `repeated` fields Field numbers larger than 15 need an additional byte to encode, so `repeated` fields
should preferrably be assigned a number between 1 and 15. If a message contains should preferably be assigned a number between 1 and 15. If a message contains
`reserved` fields, this is usually to accomodate potential future `repeated` fields. `reserved` fields, this is usually to accommodate potential future `repeated` fields.
## Implementation-Specific Notes ## Implementation-Specific Notes

View file

@ -72,7 +72,7 @@ message BackendError {
Kind kind = 2; Kind kind = 2;
// optional page in the manual // optional page in the manual
optional links.HelpPageLinkRequest.HelpPage help_page = 3; optional links.HelpPageLinkRequest.HelpPage help_page = 3;
// additional information about the context in which the error occured // additional information about the context in which the error occurred
string context = 4; string context = 4;
// a backtrace of the underlying error; requires RUST_BACKTRACE to be set // a backtrace of the underlying error; requires RUST_BACKTRACE to be set
string backtrace = 5; string backtrace = 5;

View file

@ -259,7 +259,7 @@ message CustomStudyRequest {
CRAM_KIND_ALL = 3; CRAM_KIND_ALL = 3;
} }
CramKind kind = 1; CramKind kind = 1;
// the maximimum number of cards // the maximum number of cards
uint32 card_limit = 2; uint32 card_limit = 2;
// cards must match one of these, if unempty // cards must match one of these, if unempty
repeated string tags_to_include = 3; repeated string tags_to_include = 3;

View file

@ -74,7 +74,7 @@ py_wheel(
"//platforms:macos_x86_64": "macosx_10_13_x86_64", "//platforms:macos_x86_64": "macosx_10_13_x86_64",
"//platforms:macos_arm64": "macosx_11_0_arm64", "//platforms:macos_arm64": "macosx_11_0_arm64",
# the glibc versions below are set for the official builds; # the glibc versions below are set for the official builds;
# you can adjust them to suit your enviroment # you can adjust them to suit your environment
"//platforms:linux_x86_64": "manylinux_2_28_x86_64", "//platforms:linux_x86_64": "manylinux_2_28_x86_64",
"//platforms:linux_arm64": "manylinux_2_31_aarch64", "//platforms:linux_arm64": "manylinux_2_31_aarch64",
}), }),

View file

@ -120,7 +120,7 @@ def backslashcase(string):
str1 = re.sub(r"_", r"\\", snakecase(string)) str1 = re.sub(r"_", r"\\", snakecase(string))
return str1 return str1
# return re.sub(r"\\n", "", str1)) # TODO: make regex fot \t ... # return re.sub(r"\\n", "", str1)) # TODO: make regex for \t ...
def sentencecase(string): def sentencecase(string):
@ -249,7 +249,7 @@ def alphanumcase(string):
string: String to convert. string: String to convert.
Returns: Returns:
string: String with cutted non-alphanumeric symbols. string: String with cut non-alphanumeric symbols.
""" """
# return filter(str.isalnum, str(string)) # return filter(str.isalnum, str(string))

View file

@ -23,7 +23,7 @@ class SmartDict(dict):
See http://www.peterbe.com/plog/SmartDict See http://www.peterbe.com/plog/SmartDict
Copyright 2005, Peter Bengtsson, peter@fry-it.com Copyright 2005, Peter Bengtsson, peter@fry-it.com
A smart dict can be instanciated either from a pythonic dict A smart dict can be instantiated either from a pythonic dict
or an instance object (eg. SQL recordsets) but it ensures that you can or an instance object (eg. SQL recordsets) but it ensures that you can
do all the convenient lookups such as x.first_name, x['first_name'] or do all the convenient lookups such as x.first_name, x['first_name'] or
x.get('first_name'). x.get('first_name').
@ -84,7 +84,7 @@ class SupermemoXmlImporter(NoteImporter):
""" """
def __init__(self, col: Collection, file: str) -> None: def __init__(self, col: Collection, file: str) -> None:
"""Initialize internal varables. """Initialize internal variables.
Pameters to be exposed to GUI are stored in self.META""" Pameters to be exposed to GUI are stored in self.META"""
NoteImporter.__init__(self, col, file) NoteImporter.__init__(self, col, file)
m = _legacy_add_basic_model(self.col) m = _legacy_add_basic_model(self.col)
@ -108,7 +108,7 @@ class SupermemoXmlImporter(NoteImporter):
self.cntMeta.popTitles = False self.cntMeta.popTitles = False
self.cntMeta.title = [] self.cntMeta.title = []
# META stores controls of import scritp, should be # META stores controls of import script, should be
# exposed to import dialog. These are default values. # exposed to import dialog. These are default values.
self.META = SmartDict() self.META = SmartDict()
self.META.resetLearningData = False # implemented self.META.resetLearningData = False # implemented
@ -116,7 +116,7 @@ class SupermemoXmlImporter(NoteImporter):
self.META.loggerLevel = 2 # implemented 0no,1info,2error,3debug self.META.loggerLevel = 2 # implemented 0no,1info,2error,3debug
self.META.tagAllTopics = True self.META.tagAllTopics = True
self.META.pathsToBeTagged = [ self.META.pathsToBeTagged = [
"English for begginers", "English for beginners",
"Advanced English 97", "Advanced English 97",
"Phrasal Verbs", "Phrasal Verbs",
] # path patterns to be tagged - in gui entered like 'Advanced English 97|My Vocablary' ] # path patterns to be tagged - in gui entered like 'Advanced English 97|My Vocablary'
@ -145,7 +145,7 @@ class SupermemoXmlImporter(NoteImporter):
def _decode_htmlescapes(self, html: str) -> str: def _decode_htmlescapes(self, html: str) -> str:
"""Unescape HTML code.""" """Unescape HTML code."""
# In case of bad formated html you can import MinimalSoup etc.. see BeautifulSoup source code # In case of bad formatted html you can import MinimalSoup etc.. see BeautifulSoup source code
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
# my sm2004 also ecaped & char in escaped sequences. # my sm2004 also ecaped & char in escaped sequences.
@ -254,7 +254,7 @@ class SupermemoXmlImporter(NoteImporter):
# normalize - remove diacritic punctuation from unicode chars to ascii # normalize - remove diacritic punctuation from unicode chars to ascii
item.lTitle = [self._unicode2ascii(topic) for topic in item.lTitle] item.lTitle = [self._unicode2ascii(topic) for topic in item.lTitle]
# Transfrom xyz / aaa / bbb / ccc on Title path to Tag xyzAaaBbbCcc # Transform xyz / aaa / bbb / ccc on Title path to Tag xyzAaaBbbCcc
# clean things like [999] or [111-2222] from title path, example: xyz / [1000-1200] zyx / xyz # clean things like [999] or [111-2222] from title path, example: xyz / [1000-1200] zyx / xyz
# clean whitespaces # clean whitespaces
# set Capital letters for first char of the word # set Capital letters for first char of the word
@ -405,7 +405,7 @@ class SupermemoXmlImporter(NoteImporter):
# migrate only memorized otherway skip/continue # migrate only memorized otherway skip/continue
if self.META.onlyMemorizedItems and not (int(smel.Interval) > 0): if self.META.onlyMemorizedItems and not (int(smel.Interval) > 0):
self.logger("Element skiped \t- not memorized ...", level=3) self.logger("Element skipped \t- not memorized ...", level=3)
else: else:
# import sm element data to Anki # import sm element data to Anki
self.addItemToCards(smel) self.addItemToCards(smel)
@ -418,11 +418,11 @@ class SupermemoXmlImporter(NoteImporter):
"\t{} {}".format((key + ":").ljust(15), smel[key]), level=3 "\t{} {}".format((key + ":").ljust(15), smel[key]), level=3
) )
else: else:
self.logger("Element skiped \t- no valid Q and A ...", level=3) self.logger("Element skipped \t- no valid Q and A ...", level=3)
else: else:
# now we know that item was topic # now we know that item was topic
# parseing of whole node is now finished # parsing of whole node is now finished
# test if it's really topic # test if it's really topic
if smel.Title is not None: if smel.Title is not None:

View file

@ -52,7 +52,7 @@ def _get_platform(rctx):
fail("unexpected platform", rctx.os.name) fail("unexpected platform", rctx.os.name)
def _impl(rctx): def _impl(rctx):
# bundled python overriden? # bundled python overridden?
if rctx.os.environ.get("PYO3_PYTHON"): if rctx.os.environ.get("PYO3_PYTHON"):
path = rctx.os.environ.get("PYO3_PYTHON") path = rctx.os.environ.get("PYO3_PYTHON")
rctx.symlink(path, "python") rctx.symlink(path, "python")

View file

@ -407,7 +407,7 @@ class AddonManager:
force_enable: bool = False, force_enable: bool = False,
) -> InstallOk | InstallError: ) -> InstallOk | InstallError:
"""Install add-on from path or file-like object. Metadata is read """Install add-on from path or file-like object. Metadata is read
from the manifest file, with keys overriden by supplying a 'manifest' from the manifest file, with keys overridden by supplying a 'manifest'
dictionary""" dictionary"""
try: try:
zfile = ZipFile(file) zfile = ZipFile(file)

View file

@ -275,7 +275,7 @@ class Table:
def _reset_selection(self) -> None: def _reset_selection(self) -> None:
"""Remove selection and focus without emitting signals. """Remove selection and focus without emitting signals.
If no selection change is triggerd afterwards, `browser.on_all_or_selected_rows_changed()` If no selection change is triggered afterwards, `browser.on_all_or_selected_rows_changed()`
and `browser.on_current_row_changed()` must be called. and `browser.on_current_row_changed()` must be called.
""" """
self._view.selectionModel().reset() self._view.selectionModel().reset()

View file

@ -129,7 +129,7 @@ class DeckBrowser:
_body = """ _body = """
<center> <center>
<table cellspacing=0 cellpading=3> <table cellspacing=0 cellpadding=3>
%(tree)s %(tree)s
</table> </table>

View file

@ -124,7 +124,7 @@ class ImportDialog(QDialog):
def onDelimiter(self) -> None: def onDelimiter(self) -> None:
# Open a modal dialog to enter an delimiter # Open a modal dialog to enter an delimiter
# Todo/Idea Constrain the maximum width, so it doesnt take up that much screen space # Todo/Idea Constrain the maximum width, so it doesn't take up that much screen space
delim, ok = getText( delim, ok = getText(
tr.importing_by_default_anki_will_detect_the(), tr.importing_by_default_anki_will_detect_the(),
self, self,

View file

@ -213,7 +213,7 @@ def _handle_local_file_request(request: LocalFileRequest) -> Response:
def _builtin_data(path: str) -> bytes: def _builtin_data(path: str) -> bytes:
"""Return data from file in aqt/data folder. """Return data from file in aqt/data folder.
Path must use forward slash separators.""" Path must use forward slash separators."""
# overriden location? # overridden location?
if data_folder := os.getenv("ANKI_DATA_FOLDER"): if data_folder := os.getenv("ANKI_DATA_FOLDER"):
full_path = os.path.join(data_folder, path) full_path = os.path.join(data_folder, path)
with open(full_path, "rb") as f: with open(full_path, "rb") as f:

View file

@ -792,7 +792,7 @@ time = %(time)d;
due, due,
) )
buf = "<center><table cellpading=0 cellspacing=0><tr>" buf = "<center><table cellpadding=0 cellspacing=0><tr>"
for ease, label in self._answerButtonList(): for ease, label in self._answerButtonList():
buf += but(ease, label) buf += but(ease, label)
buf += "</tr></table>" buf += "</tr></table>"

View file

@ -871,7 +871,7 @@ def current_window() -> QWidget | None:
def send_to_trash(path: Path) -> None: def send_to_trash(path: Path) -> None:
"Place file/folder in recyling bin, or delete permanently on failure." "Place file/folder in recycling bin, or delete permanently on failure."
if not path.exists(): if not path.exists():
return return
try: try:

View file

@ -175,7 +175,7 @@ class WebContent:
Important Notes: Important Notes:
- When modifying the attributes specified above, please make sure your - When modifying the attributes specified above, please make sure your
changes only perform the minimum requried edits to make your add-on work. changes only perform the minimum required edits to make your add-on work.
You should avoid overwriting or interfering with existing data as much You should avoid overwriting or interfering with existing data as much
as possible, instead opting to append your own changes, e.g.: as possible, instead opting to append your own changes, e.g.:

View file

@ -14,7 +14,7 @@
; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "$INSTDIR\myapp.exe,0" \ ; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "$INSTDIR\myapp.exe,0" \
; "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\"" ; "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\""
; ;
; Never insert the APP_ASSOCIATE macro multiple times, it is only ment ; Never insert the APP_ASSOCIATE macro multiple times, it is only meant
; to associate an application with a single file and using the ; to associate an application with a single file and using the
; the "open" verb as default. To add more verbs (actions) to a file ; the "open" verb as default. To add more verbs (actions) to a file
; use the APP_ASSOCIATE_ADDVERB macro. ; use the APP_ASSOCIATE_ADDVERB macro.

View file

@ -512,7 +512,7 @@ hooks = [
args=["columns: dict[str, aqt.browser.Column]"], args=["columns: dict[str, aqt.browser.Column]"],
doc="""Allows you to add custom columns to the browser. doc="""Allows you to add custom columns to the browser.
columns is a dictionary of data obejcts. You can add an entry with a custom columns is a dictionary of data objects. You can add an entry with a custom
column to describe how it should be displayed in the browser or modify column to describe how it should be displayed in the browser or modify
existing entries. existing entries.

View file

@ -5,7 +5,7 @@ use strum::IntoStaticStr;
use crate::prelude::*; use crate::prelude::*;
/// Auxillary deck state, stored in the config table. /// Auxiliary deck state, stored in the config table.
#[derive(Debug, Clone, Copy, IntoStaticStr)] #[derive(Debug, Clone, Copy, IntoStaticStr)]
#[strum(serialize_all = "camelCase")] #[strum(serialize_all = "camelCase")]
pub enum DeckConfigKey { pub enum DeckConfigKey {

View file

@ -255,7 +255,7 @@ fn split_and_truncate_filename(fname: &str, max_bytes: usize) -> (&str, &str) {
} }
/// Return a substring on a valid UTF8 boundary. /// Return a substring on a valid UTF8 boundary.
/// Based on a funtion in the Rust stdlib. /// Based on a function in the Rust stdlib.
fn truncated_to_char_boundary(s: &str, mut max: usize) -> &str { fn truncated_to_char_boundary(s: &str, mut max: usize) -> &str {
if max >= s.len() { if max >= s.len() {
s s

View file

@ -75,7 +75,7 @@ impl<N: Deref<Target = Notetype>> CardGenContext<N> {
} }
/// If template[ord] generates a non-empty question given nonempty_fields, return the provided /// If template[ord] generates a non-empty question given nonempty_fields, return the provided
/// deck id, or an overriden one. If question is empty, return None. /// deck id, or an overridden one. If question is empty, return None.
fn is_nonempty(&self, card_ord: usize, nonempty_fields: &HashSet<&str>) -> bool { fn is_nonempty(&self, card_ord: usize, nonempty_fields: &HashSet<&str>) -> bool {
let card = &self.cards[card_ord]; let card = &self.cards[card_ord];
let template = match card.template { let template = match card.template {

View file

@ -198,7 +198,7 @@ impl Collection {
cutoff_snapshot, cutoff_snapshot,
})); }));
} else { } else {
// we currenly allow the queues to be empty for unit tests // we currently allow the queues to be empty for unit tests
} }
Ok(()) Ok(())

View file

@ -68,7 +68,7 @@ pub fn parse_due_date_str(s: &str) -> Result<DueDateSpecifier> {
r#"(?x)^ r#"(?x)^
# a number # a number
(?P<min>\d+) (?P<min>\d+)
# an optional hypen and another number # an optional hyphen and another number
(?: (?:
- -
(?P<max>\d+) (?P<max>\d+)

View file

@ -271,7 +271,7 @@ mod test {
// with the current time being MST // with the current time being MST
let now = mst.ymd(2019, 12, 26).and_hms(20, 0, 0).timestamp(); let now = mst.ymd(2019, 12, 26).and_hms(20, 0, 0).timestamp();
assert_eq!(elap(crt, now, mdt_offset, mst_offset, 4), 507); assert_eq!(elap(crt, now, mdt_offset, mst_offset, 4), 507);
// the previous implementation generated a diferent elapsed number of days with a change // the previous implementation generated a different elapsed number of days with a change
// to DST, but the number shouldn't change // to DST, but the number shouldn't change
assert_eq!(elap(crt, now, mdt_offset, mdt_offset, 4), 507); assert_eq!(elap(crt, now, mdt_offset, mdt_offset, 4), 507);

View file

@ -9,7 +9,7 @@ use super::{is_tag_separator, join_tags, split_tags};
use crate::{notes::NoteTags, prelude::*}; use crate::{notes::NoteTags, prelude::*};
impl Collection { impl Collection {
/// Replace occurences of a search with a new value in tags. /// Replace occurrences of a search with a new value in tags.
pub fn find_and_replace_tag( pub fn find_and_replace_tag(
&mut self, &mut self,
nids: &[NoteId], nids: &[NoteId],

View file

@ -87,7 +87,7 @@ impl TimestampMillis {
fn elapsed() -> time::Duration { fn elapsed() -> time::Duration {
if *crate::PYTHON_UNIT_TESTS { if *crate::PYTHON_UNIT_TESTS {
// shift clock around rollover time to accomodate Python tests that make bad assumptions. // shift clock around rollover time to accommodate Python tests that make bad assumptions.
// we should update the tests in the future and remove this hack. // we should update the tests in the future and remove this hack.
let mut elap = time::SystemTime::now() let mut elap = time::SystemTime::now()
.duration_since(time::SystemTime::UNIX_EPOCH) .duration_since(time::SystemTime::UNIX_EPOCH)

View file

@ -12,7 +12,7 @@ export interface SurroundFormat<T = never> {
*/ */
matcher: (element: HTMLElement | SVGElement, match: MatchType<T>) => void; matcher: (element: HTMLElement | SVGElement, match: MatchType<T>) => void;
/** /**
* @returns Whehter before or after are allowed to merge to a single * @returns Whether before or after are allowed to merge to a single
* FormattingNode range * FormattingNode range
*/ */
merger?: (before: FormattingNode<T>, after: FormattingNode<T>) => boolean; merger?: (before: FormattingNode<T>, after: FormattingNode<T>) => boolean;

View file

@ -381,7 +381,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Serves as a pre-slotted convenience component which combines all the common Serves as a pre-slotted convenience component which combines all the common
components and functionality for general note editing. components and functionality for general note editing.
Functionality exclusive to specifc note-editing views (e.g. in the browser or Functionality exclusive to specific note-editing views (e.g. in the browser or
the AddCards dialog) should be implemented in the user of this component. the AddCards dialog) should be implemented in the user of this component.
--> -->
<div class="note-editor" bind:clientHeight> <div class="note-editor" bind:clientHeight>

View file

@ -8,7 +8,7 @@ import type { SymbolsTable } from "./symbols-types";
// Not all characters work well in the editor field // Not all characters work well in the editor field
delete characterEntities["Tab"]; delete characterEntities["Tab"];
// A single character entity can be present under differnet names // A single character entity can be present under different names
// So we change the mapping to symbol => name[] // So we change the mapping to symbol => name[]
const characterTable: Record<string, string[]> = {}; const characterTable: Record<string, string[]> = {};

View file

@ -26,7 +26,7 @@ interface ClosingClickArgs {
/** /**
* Returns a derived store, which translates `MouseEvent`s into a boolean * Returns a derived store, which translates `MouseEvent`s into a boolean
* indicating whether they constitue a click that should close `floating`. * indicating whether they constitute a click that should close `floating`.
* *
* @param: Should be an event store wrapping document.click. * @param: Should be an event store wrapping document.click.
*/ */

View file

@ -17,7 +17,7 @@ interface ClosingKeyupArgs {
/** /**
* Returns a derived store, which translates `MouseEvent`s into a boolean * Returns a derived store, which translates `MouseEvent`s into a boolean
* indicating whether they constitue a click that should close `floating`. * indicating whether they constitute a click that should close `floating`.
* *
* @param: Should be an event store wrapping document.click. * @param: Should be an event store wrapping document.click.
*/ */

View file

@ -69,7 +69,7 @@ export interface DynamicSlottingAPI<
* Allow add-on developers to dynamically extend/modify components our components * Allow add-on developers to dynamically extend/modify components our components
* *
* @remarks * @remarks
* It allows to insert elements inbetween the components, or modify their props. * It allows to insert elements in between the components, or modify their props.
* Practically speaking, we let Svelte do the initial insertion of an element, * Practically speaking, we let Svelte do the initial insertion of an element,
* but then immediately move it to its destination, and save a reference to it. * but then immediately move it to its destination, and save a reference to it.
* *