mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
configs.proto plural workaround no longer necessary
This commit is contained in:
parent
e61a611af7
commit
0e7411188b
12 changed files with 21 additions and 21 deletions
|
@ -14,7 +14,7 @@ enum ServiceIndex {
|
||||||
SERVICE_INDEX_NOTES = 2;
|
SERVICE_INDEX_NOTES = 2;
|
||||||
SERVICE_INDEX_SYNC = 3;
|
SERVICE_INDEX_SYNC = 3;
|
||||||
SERVICE_INDEX_NOTETYPES = 4;
|
SERVICE_INDEX_NOTETYPES = 4;
|
||||||
SERVICE_INDEX_CONFIGS = 5;
|
SERVICE_INDEX_CONFIG = 5;
|
||||||
SERVICE_INDEX_CARD_RENDERING = 6;
|
SERVICE_INDEX_CARD_RENDERING = 6;
|
||||||
SERVICE_INDEX_DECK_CONFIG = 7;
|
SERVICE_INDEX_DECK_CONFIG = 7;
|
||||||
SERVICE_INDEX_TAGS = 8;
|
SERVICE_INDEX_TAGS = 8;
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package anki.configs;
|
package anki.config;
|
||||||
|
|
||||||
import "anki/generic.proto";
|
import "anki/generic.proto";
|
||||||
import "anki/collection.proto";
|
import "anki/collection.proto";
|
||||||
|
|
||||||
service ConfigsService {
|
service ConfigService {
|
||||||
rpc GetConfigJson(generic.String) returns (generic.Json);
|
rpc GetConfigJson(generic.String) returns (generic.Json);
|
||||||
rpc SetConfigJson(SetConfigJsonRequest) returns (collection.OpChanges);
|
rpc SetConfigJson(SetConfigJsonRequest) returns (collection.OpChanges);
|
||||||
rpc SetConfigJsonNoUndo(SetConfigJsonRequest) returns (generic.Empty);
|
rpc SetConfigJsonNoUndo(SetConfigJsonRequest) returns (generic.Empty);
|
|
@ -9,7 +9,7 @@ import "anki/generic.proto";
|
||||||
import "anki/cards.proto";
|
import "anki/cards.proto";
|
||||||
import "anki/decks.proto";
|
import "anki/decks.proto";
|
||||||
import "anki/collection.proto";
|
import "anki/collection.proto";
|
||||||
import "anki/configs.proto";
|
import "anki/config.proto";
|
||||||
|
|
||||||
service SchedulerService {
|
service SchedulerService {
|
||||||
rpc GetQueuedCards(GetQueuedCardsRequest) returns (QueuedCards);
|
rpc GetQueuedCards(GetQueuedCardsRequest) returns (QueuedCards);
|
||||||
|
@ -178,7 +178,7 @@ message ScheduleCardsAsNewRequest {
|
||||||
message SetDueDateRequest {
|
message SetDueDateRequest {
|
||||||
repeated int64 card_ids = 1;
|
repeated int64 card_ids = 1;
|
||||||
string days = 2;
|
string days = 2;
|
||||||
configs.OptionalStringConfigKey config_key = 3;
|
config.OptionalStringConfigKey config_key = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SortCardsRequest {
|
message SortCardsRequest {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import anki.notes_pb2
|
||||||
import anki.notetypes_pb2
|
import anki.notetypes_pb2
|
||||||
import anki.scheduler_pb2
|
import anki.scheduler_pb2
|
||||||
import anki.sync_pb2
|
import anki.sync_pb2
|
||||||
import anki.configs_pb2
|
import anki.config_pb2
|
||||||
import anki.search_pb2
|
import anki.search_pb2
|
||||||
import anki.stats_pb2
|
import anki.stats_pb2
|
||||||
import anki.card_rendering_pb2
|
import anki.card_rendering_pb2
|
||||||
|
@ -189,7 +189,7 @@ service_modules = dict(
|
||||||
NOTETYPES=anki.notetypes_pb2,
|
NOTETYPES=anki.notetypes_pb2,
|
||||||
SCHEDULER=anki.scheduler_pb2,
|
SCHEDULER=anki.scheduler_pb2,
|
||||||
SYNC=anki.sync_pb2,
|
SYNC=anki.sync_pb2,
|
||||||
CONFIGS=anki.configs_pb2,
|
CONFIG=anki.config_pb2,
|
||||||
SEARCH=anki.search_pb2,
|
SEARCH=anki.search_pb2,
|
||||||
STATS=anki.stats_pb2,
|
STATS=anki.stats_pb2,
|
||||||
CARD_RENDERING=anki.card_rendering_pb2,
|
CARD_RENDERING=anki.card_rendering_pb2,
|
||||||
|
@ -240,7 +240,7 @@ import anki.notes_pb2
|
||||||
import anki.notetypes_pb2
|
import anki.notetypes_pb2
|
||||||
import anki.scheduler_pb2
|
import anki.scheduler_pb2
|
||||||
import anki.sync_pb2
|
import anki.sync_pb2
|
||||||
import anki.configs_pb2
|
import anki.config_pb2
|
||||||
import anki.search_pb2
|
import anki.search_pb2
|
||||||
import anki.stats_pb2
|
import anki.stats_pb2
|
||||||
import anki.card_rendering_pb2
|
import anki.card_rendering_pb2
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Any, Generator, List, Literal, Optional, Sequence, Tuple, Uni
|
||||||
from anki import (
|
from anki import (
|
||||||
card_rendering_pb2,
|
card_rendering_pb2,
|
||||||
collection_pb2,
|
collection_pb2,
|
||||||
configs_pb2,
|
config_pb2,
|
||||||
generic_pb2,
|
generic_pb2,
|
||||||
search_pb2,
|
search_pb2,
|
||||||
stats_pb2,
|
stats_pb2,
|
||||||
|
@ -22,7 +22,7 @@ SearchNode = search_pb2.SearchNode
|
||||||
Progress = collection_pb2.Progress
|
Progress = collection_pb2.Progress
|
||||||
EmptyCardsReport = card_rendering_pb2.EmptyCardsReport
|
EmptyCardsReport = card_rendering_pb2.EmptyCardsReport
|
||||||
GraphPreferences = stats_pb2.GraphPreferences
|
GraphPreferences = stats_pb2.GraphPreferences
|
||||||
Preferences = configs_pb2.Preferences
|
Preferences = config_pb2.Preferences
|
||||||
UndoStatus = collection_pb2.UndoStatus
|
UndoStatus = collection_pb2.UndoStatus
|
||||||
OpChanges = collection_pb2.OpChanges
|
OpChanges = collection_pb2.OpChanges
|
||||||
OpChangesWithCount = collection_pb2.OpChangesWithCount
|
OpChangesWithCount = collection_pb2.OpChangesWithCount
|
||||||
|
|
|
@ -25,12 +25,12 @@ from typing import Any
|
||||||
from weakref import ref
|
from weakref import ref
|
||||||
|
|
||||||
import anki
|
import anki
|
||||||
from anki import configs_pb2
|
from anki import config_pb2
|
||||||
from anki.collection import OpChanges
|
from anki.collection import OpChanges
|
||||||
from anki.errors import NotFoundError
|
from anki.errors import NotFoundError
|
||||||
from anki.utils import from_json_bytes, to_json_bytes
|
from anki.utils import from_json_bytes, to_json_bytes
|
||||||
|
|
||||||
Config = configs_pb2.ConfigKey
|
Config = config_pb2.ConfigKey
|
||||||
|
|
||||||
|
|
||||||
class ConfigManager:
|
class ConfigManager:
|
||||||
|
|
1
pylib/anki/config_pb2.pyi
Symbolic link
1
pylib/anki/config_pb2.pyi
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../bazel-bin/pylib/anki/config_pb2.pyi
|
|
@ -1 +0,0 @@
|
||||||
../../bazel-bin/pylib/anki/configs_pb2.pyi
|
|
|
@ -17,7 +17,7 @@ FilteredDeckForUpdate = decks_pb2.FilteredDeckForUpdate
|
||||||
|
|
||||||
from typing import List, Optional, Sequence
|
from typing import List, Optional, Sequence
|
||||||
|
|
||||||
from anki import configs_pb2
|
from anki import config_pb2
|
||||||
from anki.cards import CardId
|
from anki.cards import CardId
|
||||||
from anki.consts import CARD_TYPE_NEW, NEW_CARDS_RANDOM, QUEUE_TYPE_NEW, QUEUE_TYPE_REV
|
from anki.consts import CARD_TYPE_NEW, NEW_CARDS_RANDOM, QUEUE_TYPE_NEW, QUEUE_TYPE_REV
|
||||||
from anki.decks import DeckConfigDict, DeckId, DeckTreeNode
|
from anki.decks import DeckConfigDict, DeckId, DeckTreeNode
|
||||||
|
@ -167,9 +167,9 @@ select id from cards where did in %s and queue = {QUEUE_TYPE_REV} and due <= ? l
|
||||||
"""Set cards to be due in `days`, turning them into review cards if necessary.
|
"""Set cards to be due in `days`, turning them into review cards if necessary.
|
||||||
`days` can be of the form '5' or '5..7'
|
`days` can be of the form '5' or '5..7'
|
||||||
If `config_key` is provided, provided days will be remembered in config."""
|
If `config_key` is provided, provided days will be remembered in config."""
|
||||||
key: Optional[configs_pb2.OptionalStringConfigKey]
|
key: Optional[config_pb2.OptionalStringConfigKey]
|
||||||
if config_key is not None:
|
if config_key is not None:
|
||||||
key = configs_pb2.OptionalStringConfigKey(key=config_key)
|
key = config_pb2.OptionalStringConfigKey(key=config_key)
|
||||||
else:
|
else:
|
||||||
key = None
|
key = None
|
||||||
return self.col._backend.set_due_date(
|
return self.col._backend.set_due_date(
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use super::Backend;
|
use super::Backend;
|
||||||
pub(super) use crate::backend_proto::configs_service::Service as ConfigsService;
|
pub(super) use crate::backend_proto::config_service::Service as ConfigService;
|
||||||
use crate::{
|
use crate::{
|
||||||
backend_proto as pb,
|
backend_proto as pb,
|
||||||
backend_proto::config_key::{Bool as BoolKeyProto, String as StringKeyProto},
|
backend_proto::config_key::{Bool as BoolKeyProto, String as StringKeyProto},
|
||||||
|
@ -46,7 +46,7 @@ impl From<StringKeyProto> for StringKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigsService for Backend {
|
impl ConfigService for Backend {
|
||||||
fn get_config_json(&self, input: pb::String) -> Result<pb::Json> {
|
fn get_config_json(&self, input: pb::String) -> Result<pb::Json> {
|
||||||
self.with_col(|col| {
|
self.with_col(|col| {
|
||||||
let val: Option<Value> = col.get_config_optional(input.val.as_str());
|
let val: Option<Value> = col.get_config_optional(input.val.as_str());
|
||||||
|
|
|
@ -40,7 +40,7 @@ use self::{
|
||||||
card::CardsService,
|
card::CardsService,
|
||||||
cardrendering::CardRenderingService,
|
cardrendering::CardRenderingService,
|
||||||
collection::CollectionService,
|
collection::CollectionService,
|
||||||
config::ConfigsService,
|
config::ConfigService,
|
||||||
deckconfig::DeckConfigService,
|
deckconfig::DeckConfigService,
|
||||||
decks::DecksService,
|
decks::DecksService,
|
||||||
i18n::I18nService,
|
i18n::I18nService,
|
||||||
|
@ -121,7 +121,7 @@ impl Backend {
|
||||||
pb::ServiceIndex::Decks => DecksService::run_method(self, method, input),
|
pb::ServiceIndex::Decks => DecksService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::Notes => NotesService::run_method(self, method, input),
|
pb::ServiceIndex::Notes => NotesService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::Notetypes => NotetypesService::run_method(self, method, input),
|
pb::ServiceIndex::Notetypes => NotetypesService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::Configs => ConfigsService::run_method(self, method, input),
|
pb::ServiceIndex::Config => ConfigService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::Sync => SyncService::run_method(self, method, input),
|
pb::ServiceIndex::Sync => SyncService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::Tags => TagsService::run_method(self, method, input),
|
pb::ServiceIndex::Tags => TagsService::run_method(self, method, input),
|
||||||
pb::ServiceIndex::DeckConfig => DeckConfigService::run_method(self, method, input),
|
pb::ServiceIndex::DeckConfig => DeckConfigService::run_method(self, method, input),
|
||||||
|
|
|
@ -17,7 +17,7 @@ protobuf!(backend);
|
||||||
protobuf!(card_rendering);
|
protobuf!(card_rendering);
|
||||||
protobuf!(cards);
|
protobuf!(cards);
|
||||||
protobuf!(collection);
|
protobuf!(collection);
|
||||||
protobuf!(configs);
|
protobuf!(config);
|
||||||
protobuf!(deckconfig);
|
protobuf!(deckconfig);
|
||||||
protobuf!(decks);
|
protobuf!(decks);
|
||||||
protobuf!(generic);
|
protobuf!(generic);
|
||||||
|
|
Loading…
Reference in a new issue