summaryrefslogtreecommitdiffstats
path: root/quickstart/template.py
blob: ead6874c27a21b52ef7e5689cab1372595adb9e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# Example quickstart template for designing new ontologies

from sys import argv
#from genshi.input import XML

from ontogen.ontogen import Property, Class, Example, OntologyWithFigure, \
                            Ontologies

#from ontogen.ontogen import log
#log.setLevel('DEBUG')

BASE = 'http://example.org/net/template'


#
# classes
#


# v0.1

class Foo(Class):
    """abstract foo item, use only its subclasses"""


class TFoo(Foo):
    """T-shaped foo

    Represents foos that are special because of the T-shape.
    """


#
# properties
#

# v0.1

@Foo.inDomainOf
class bar(Property):
    """plain bar

    Connects resources with foos.
    """
    range = "http://www.w3.org/2001/XMLSchema#string"


class baz(bar):
    """bar specialization known as baz"""


#
# examples
#


class ex_0_1(Example):
    """An example snippet.

<tmpl:tfoo about="#mytfoo">
  <tmpl:baz>test</tmpl:baz>
</tmpl:tfoo>
    """
    pfx = 'tmpl:'


#
# ontology + versions
#


ontologies = Ontologies()


class template(OntologyWithFigure):
    """Descriptive vocabulary for foos

    This vocabulary serves a purpose of shedding light into semantics
    in the field of foos.
    """
    base_uri = BASE
    #creator = XML('''\
    #    <dc:X xmlns:dc="http://purl.org/dc/elements/1.1/"
    #    >John Doe</dc:X>''')
    creator = 'John Doe'


@ontologies.include
class template_0_1(template):
    version = '0.1'
    issued = '2013-02-19'
    modified = '2013-03-20'
    classes = [
        Foo,
        TFoo,
    ]
    properties = [
        bar,
        baz,
    ]
    examples = [
        ex_0_1,
    ]


#@ontologies.include
#@template_0_1.supersededBy
#class template_0_2(template):
#    ...


if __name__ == '__main__':
    ontologies.generate_latest(**(len(argv) > 1 and {'outfile': argv[1]} or {}))