Source code for timApp.admin.timitemtype

from typing import Any

import click

from timApp.document.docentry import DocEntry
from timApp.folder.folder import Folder
from timApp.item.item import Item


[docs]class TimItemType(click.ParamType): """TIM item.""" name = "timitem"
[docs] def convert(self, value: Any, param: Any, ctx: Any) -> Item: d = DocEntry.find_by_path(value) if d: return d f = Folder.find_by_path(value) if f: return f self.fail(f"Item {value} not found.")
[docs]class TimDocumentType(click.ParamType): """TIM document.""" name = "timdocument"
[docs] def convert(self, value: Any, param: Any, ctx: Any) -> Item: d = DocEntry.find_by_path(value) if d: return d self.fail(f"Document {value} not found.")