add apis to retrieve full model data by name and id
This commit is contained in:
parent
2de0798fc1
commit
50d062e6ca
@ -1111,6 +1111,28 @@ class AnkiConnect:
|
|||||||
return models
|
return models
|
||||||
|
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def findModelsById(self, modelIds):
|
||||||
|
models = []
|
||||||
|
for id in modelIds:
|
||||||
|
model = self.collection().models.get(id)
|
||||||
|
if model is None:
|
||||||
|
raise Exception("model was not found: {}".format(id))
|
||||||
|
else:
|
||||||
|
models.append(model)
|
||||||
|
return models
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def findModelsByName(self, modelNames):
|
||||||
|
models = []
|
||||||
|
for name in modelNames:
|
||||||
|
model = self.collection().models.byName(name)
|
||||||
|
if model is None:
|
||||||
|
raise Exception("model was not found: {}".format(name))
|
||||||
|
else:
|
||||||
|
models.append(model)
|
||||||
|
return models
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def modelNameFromId(self, modelId):
|
def modelNameFromId(self, modelId):
|
||||||
model = self.collection().models.get(modelId)
|
model = self.collection().models.get(modelId)
|
||||||
|
Loading…
Reference in New Issue
Block a user