Skip to content

Commit 70e7e36

Browse files
committed
squash/drop: Remove top-level schema namespace
Signed-off-by: David Feltell <[email protected]>
1 parent 1fbaee9 commit 70e7e36

File tree

16 files changed

+498
-762
lines changed

16 files changed

+498
-762
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/OpenAssetIO/OpenAssetIO-TraitGen/main/python/openassetio_traitgen/schema.json
2+
# yamllint disable-line rule:document-start
3+
package: openassetio-example
4+
description: An example traits schema
5+
6+
traits:
7+
example:
8+
description: Example namespace
9+
members:
10+
11+
Deprecated:
12+
deprecated: true
13+
versions:
14+
- description: An example.
15+
usage:
16+
- entity
17+
- locale
18+
- relationship
19+
20+
Added:
21+
versions:
22+
- description: An example.
23+
usage:
24+
- entity
25+
- locale
26+
- relationship
27+
28+
Updated:
29+
versions:
30+
- description: An example.
31+
usage:
32+
- entity
33+
- locale
34+
- relationship
35+
properties:
36+
propertyToKeep:
37+
type: string
38+
description: A property that is unchanged between versions.
39+
propertyToRename:
40+
type: boolean
41+
description: >
42+
A property that has an inappropriate name and should be renamed in the
43+
next version.
44+
propertyToRemove:
45+
type: boolean
46+
description: A defunct property that should be removed in the next version.
47+
- description: An example.
48+
usage:
49+
- entity
50+
- locale
51+
- relationship
52+
properties:
53+
propertyToKeep:
54+
type: string
55+
description: A property that is unchanged between versions.
56+
propertyThatWasRenamed:
57+
type: boolean
58+
description: A property that has been renamed.
59+
propertyThatWasAdded:
60+
type: float
61+
description: A new property added in the latest version.
62+
63+
specifications:
64+
example:
65+
description: Test specifications.
66+
members:
67+
68+
Example:
69+
versions:
70+
- description: An example.
71+
usage:
72+
- entity
73+
traitSet:
74+
- namespace: example
75+
name: Added
76+
version: 1
77+
- namespace: example
78+
name: Updated
79+
version: 1
80+
- description: An example.
81+
usage:
82+
- entity
83+
traitSet:
84+
- namespace: example
85+
name: Added
86+
version: 1
87+
- namespace: example
88+
name: Updated
89+
version: 2

examples/resources/working_with_trait_versions/openassetio_example/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
# WARNING: This file is auto-generated by openassetio-traitgen, do not edit.
66

7-
from .v2 import *
7+
from . import traits
8+
from . import specifications
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
2+
"""
3+
Specification definitions in the 'example' namespace.
4+
5+
Test specifications.
6+
"""
7+
8+
# WARNING: This file is auto-generated by openassetio-traitgen, do not edit.
9+
10+
from openassetio.trait import TraitsData
11+
12+
13+
from .. import traits
14+
15+
16+
class ExampleSpecification_v2:
17+
"""
18+
An example.
19+
Usage: entity
20+
"""
21+
kTraitSet = {
22+
# 'openassetio-example:example.Deprecated'
23+
traits.example.AddedTrait_v1.kId,
24+
# 'openassetio-example:example.Updated'
25+
traits.example.UpdatedTrait_v2.kId,
26+
27+
}
28+
29+
def __init__(self, traitsData):
30+
"""
31+
Constructs the specification as a view on the supplied
32+
shared @fqref{TraitsData} "TraitsData" instance.
33+
34+
@param traitsData @fqref{TraitsData} "TraitsData"
35+
36+
@warning Specifications are always a view on the supplied data,
37+
which is held by reference. Any changes made to the data will be
38+
visible to any other specifications or @ref trait "traits" that
39+
wrap the same TraitsData instance.
40+
"""
41+
if not isinstance(traitsData, TraitsData):
42+
raise TypeError("Specifications must be constructed with a TraitsData instance")
43+
self.__data = traitsData
44+
45+
def traitsData(self):
46+
"""
47+
Returns the underlying (shared) @fqref{TraitsData} "TraitsData"
48+
instance held by this specification.
49+
"""
50+
return self.__data
51+
52+
@classmethod
53+
def create(cls):
54+
"""
55+
Returns a new instance of the Specification, holding a new
56+
@fqref{TraitsData} "TraitsData" instance, pre-populated with all
57+
of the specifications traits.
58+
"""
59+
data = TraitsData(cls.kTraitSet)
60+
return cls(data)
61+
62+
def deprectatedTrait(self):
63+
"""
64+
Returns the view for the 'openassetio-example:example.Unchanged' trait wrapped around
65+
the data held in this instance.
66+
"""
67+
return traits.example.DeprecatedTrait_v1(self.traitsData())
68+
69+
def updatedTrait(self):
70+
"""
71+
Returns the view for the 'openassetio-example:example.Updated' trait wrapped around
72+
the data held in this instance.
73+
"""
74+
return traits.example.UpdatedTrait_v2(self.traitsData())
75+
76+
77+
# Alias for latest version.
78+
ExampleSpecification = ExampleSpecification_v2
79+
80+
81+
class ExampleSpecification_v1:
82+
"""
83+
An example.
84+
Usage: entity
85+
"""
86+
kTraitSet = {
87+
# 'openassetio-example:example.Deprecated'
88+
traits.example.AddedTrait_v1.kId,
89+
# 'openassetio-example:example.Updated'
90+
traits.example.UpdatedTrait_v1.kId,
91+
92+
}
93+
94+
def __init__(self, traitsData):
95+
"""
96+
Constructs the specification as a view on the supplied
97+
shared @fqref{TraitsData} "TraitsData" instance.
98+
99+
@param traitsData @fqref{TraitsData} "TraitsData"
100+
101+
@warning Specifications are always a view on the supplied data,
102+
which is held by reference. Any changes made to the data will be
103+
visible to any other specifications or @ref trait "traits" that
104+
wrap the same TraitsData instance.
105+
"""
106+
if not isinstance(traitsData, TraitsData):
107+
raise TypeError("Specifications must be constructed with a TraitsData instance")
108+
self.__data = traitsData
109+
110+
def traitsData(self):
111+
"""
112+
Returns the underlying (shared) @fqref{TraitsData} "TraitsData"
113+
instance held by this specification.
114+
"""
115+
return self.__data
116+
117+
@classmethod
118+
def create(cls):
119+
"""
120+
Returns a new instance of the Specification, holding a new
121+
@fqref{TraitsData} "TraitsData" instance, pre-populated with all
122+
of the specifications traits.
123+
"""
124+
data = TraitsData(cls.kTraitSet)
125+
return cls(data)
126+
127+
128+
def deprectatedTrait(self):
129+
"""
130+
Returns the view for the 'openassetio-example:example.Unchanged' trait wrapped around
131+
the data held in this instance.
132+
"""
133+
return traits.example.DeprecatedTrait_v1(self.traitsData())
134+
135+
def updatedTrait(self):
136+
"""
137+
Returns the view for the 'openassetio-example:example.Updated' trait wrapped around
138+
the data held in this instance.
139+
"""
140+
return traits.example.UpdatedTrait_v1(self.traitsData())

0 commit comments

Comments
 (0)