summaryrefslogtreecommitdiffstats
path: root/template.py
blob: e2a1a39b5fe75bbb4b242dcad75d76a1647cec83 (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
115
116
#!/usr/bin/env python
# Example quickstart template for designing new ontologies

from sys import argv
#from genshi.input import XML

from ontologygen import Property, Class, Example, Ontology, Ontologies

BASE = 'http://purl.org/net/foo'


#
# 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
#

# v0.1

class ex_0_1_schema(Example):
    """Illustrative figure of the vocabulary."""
    image = '0.2.svg'


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

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


#
# ontology + versions
#


ontologies = Ontologies()


class foo(Ontology):
    """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:foo xmlns:dc="http://purl.org/dc/elements/1.1/"
    #    >John Doe</dc:foo>''')
    creator = 'John Doe'


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


#@ontologies.include
#@foo_0_1.supersededBy
#class foo_0_2(foo):
#    ...


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