Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skeleton #182

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iiif_prezi3/helpers/auto_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ def __init__(self):
# Set up some obvious defaults
ai.register_on_class(AnnotationPage, Class)
al.register_on_class(KeyValueString, Class, Reference)
ait.register_on_class(Canvas, Range)
ait.register_on_class(Canvas, Range, AnnotationPage)
alst.register_on_class(Class, AnnotationPage, ResourceItem, ServiceItem1, NavPlace, Reference, ProviderItem)
allst.register_on_class(HomepageItem)
81 changes: 54 additions & 27 deletions iiif_prezi3/skeleton.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: iiif_3_0.json
# timestamp: 2023-02-17T13:09:25+00:00
# timestamp: 2023-06-01T15:24:07+00:00

from __future__ import annotations

Expand Down Expand Up @@ -56,7 +56,7 @@ class ViewingDirection(Base):


class Id(Base):
__root__: AnyUrl = Field(..., title='Id must be presesnt and must be a URI')
__root__: AnyUrl = Field(..., title='Id must be present and must be a URI')


class LngString(Base):
Expand Down Expand Up @@ -94,13 +94,33 @@ class Format(Base):
__root__: constr(regex=r'^[a-z][a-z]*/.*$')


class AnnoSelectorItem(Base):
class SelectorItem(Base):
type: str
t: Optional[Duration] = None
t: Duration


class AnnoSelector(Base):
__root__: Union[AnyUrl, AnnoSelectorItem]
class SelectorItem1(Base):
type: constr(regex=r'^FragmentSelector$') = 'FragmentSelector'
conformsTo: AnyUrl = 'http://www.w3.org/TR/media-frags/'
value: Any


class SelectorItem2(Base):
type: constr(regex=r'^SvgSelector$') = 'SvgSelector'
value: Any


class SelectorItem3(Base):
type: constr(regex=r'^ImageApiSelector$') = 'ImageApiSelector'
region: Optional[Any] = None
size: Optional[Any] = None
rotation: Optional[Any] = None
quality: Optional[Any] = None
format: Optional[Any] = None


class Selector(Base):
__root__: Union[AnyUrl, SelectorItem, SelectorItem1, SelectorItem2, SelectorItem3]


class NavPlace(Base):
Expand Down Expand Up @@ -142,8 +162,8 @@ class SpecificResource(Base):
type: constr(regex=r'^SpecificResource$') = 'SpecificResource'
format: Optional[Format] = None
accessibility: Optional[str] = None
source: Id
selector: Union[AnnoSelector, List[AnnoSelector]]
source: Union[Id, Class]
selector: Union[Selector, List[Selector]]


class HomepageItem(Class):
Expand All @@ -165,6 +185,7 @@ class PartOf(Base):

class Item(Class):
type: constr(regex=r'^Canvas$') = 'Canvas'
items: List


class SeeAlso(Base):
Expand All @@ -179,18 +200,15 @@ class Model(Base):
__root__: Union[Manifest, Collection, AnnotationPage]


class AnnotationPage(Base):
class Config:
extra = Extra.forbid

context: Optional[Any] = Field(None, alias='@context')
class AnnotationPage(Class):
context: Optional[Union[List[AnyUrl], str]] = Field(None, alias='@context')
id: Id
type: constr(regex=r'^AnnotationPage$') = 'AnnotationPage'
rendering: Optional[External] = None
label: Optional[LngString] = None
service: Optional[Service] = None
thumbnail: Optional[List[Resource]] = None
items: Optional[List[Annotation]] = None
items: List[Annotation]


class Collection(Class):
Expand All @@ -217,7 +235,7 @@ class Collection(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: Optional[List[Union[ManifestRef, CollectionRef, Collection]]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class Manifest(Class):
Expand Down Expand Up @@ -246,7 +264,7 @@ class Manifest(Class):
partOf: Optional[PartOf] = None
items: Optional[List[Canvas]] = None
structures: Optional[List[Range]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class AccompanyingCanvas(Class):
Expand All @@ -269,7 +287,7 @@ class AccompanyingCanvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class BodyItem(Choice):
Expand Down Expand Up @@ -308,7 +326,7 @@ class Canvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class PlaceholderCanvas(Class):
Expand All @@ -331,7 +349,7 @@ class PlaceholderCanvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class ProviderItem(Class):
Expand All @@ -352,9 +370,9 @@ class Range(Class):
service: Optional[Service] = None
placeholderCanvas: Optional[PlaceholderCanvas] = None
accompanyingCanvas: Optional[AccompanyingCanvas] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None
thumbnail: Optional[List[Resource]] = None
items: List[Union[SpecificResource, Item, Range, CanvasRef, RangeRef]]
items: List[Union[SpecificResource, Item, Range, CanvasRef]]


class ResourceItem(Base):
Expand All @@ -369,7 +387,7 @@ class ResourceItem(Base):
format: Optional[Format] = None
label: Optional[LngString] = None
thumbnail: Optional[List[Resource]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[List[Union[AnnotationPage, AnnotationPageRef]]] = None


class Resource(Base):
Expand All @@ -396,29 +414,37 @@ class AnnotationCollection(Class):
type: constr(regex=r'^AnnotationCollection$') = 'AnnotationCollection'
rendering: Optional[External] = None
partOf: Optional[PartOf] = None
next: Optional[AnnotationPage] = None
first: Optional[AnnotationPage] = None
last: Optional[AnnotationPage] = None
next: Optional[AnnotationPageRef] = None
first: Optional[AnnotationPageRef] = None
last: Optional[AnnotationPageRef] = None
service: Optional[Service] = None
thumbnail: Optional[List[Resource]] = None
items: Optional[List[Annotation]] = None


class Reference(Base):
class Config:
extra = Extra.allow

id: Id
label: LngString
label: Optional[LngString] = None
type: constr(
regex=r'^Manifest$|^AnnotationPage$|^Collection$|^AnnotationCollection$|^Canvas$|^Range$'
)
thumbnail: Optional[List[Resource]] = None


class AnnotationPageRef(Reference):
type: Optional[constr(regex=r'^AnnotationPage$')] = None


class CollectionRef(Reference):
type: Optional[constr(regex=r'^Collection$')] = None
label: LngString


class ManifestRef(Reference):
type: Optional[constr(regex=r'^Manifest$')] = None
type: constr(regex=r'^Manifest$') = 'Manifest'

class Config:
extra = Extra.allow
Expand Down Expand Up @@ -446,3 +472,4 @@ class RangeRef(Reference):
ResourceItem.update_forward_refs()
ServiceItem.update_forward_refs()
ServiceItem1.update_forward_refs()
AnnotationCollection.update_forward_refs()
9 changes: 8 additions & 1 deletion utils/modify_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
{
"description": "Allow extra properties on ManifestRef",
"type": "insert",
"before": "class ManifestRef(Reference):\n type: Optional[constr(regex=r'^Manifest$')] = None\n",
"before": "class ManifestRef(Reference):\n type: constr(regex=r'^Manifest$') = 'Manifest'\n",
"after": "\n\nclass CanvasRef(Reference):",
"data": "\n class Config:\n extra = Extra.allow\n"
},
{
"description": "Re-add RangeRef",
"type": "insert",
"before": "class CanvasRef(Reference):\n type: Optional[constr(regex=r'^Canvas$')] = None\n",
"after": "\n\nModel.update_forward_refs()",
"data": "\n\nclass RangeRef(Reference):\n type: Optional[constr(regex=r'^Range$')] = None\n"
}
]

Expand Down