|
@@ -1,137 +0,0 @@
|
1
|
|
-from django.core.management.base import BaseCommand, CommandError
|
2
|
|
-from optparse import make_option
|
3
|
|
-from EditorialModel.randomem import RandomEm
|
4
|
|
-from EditorialModel.backend.json_backend import EmBackendJson
|
5
|
|
-from EditorialModel.backend.dummy_backend import EmBackendDummy
|
6
|
|
-from EditorialModel.backend.graphviz import EmBackendGraphviz
|
7
|
|
-
|
8
|
|
-
|
9
|
|
-class Command(BaseCommand):
|
10
|
|
- option_list = BaseCommand.option_list + (
|
11
|
|
- make_option('--no-classes',
|
12
|
|
- action='store',
|
13
|
|
- dest='classtype',
|
14
|
|
- default = 0,
|
15
|
|
- help='Chances for a classtype to be empty',
|
16
|
|
- type="int",
|
17
|
|
- metavar="INT",
|
18
|
|
- ),
|
19
|
|
- make_option('--max-classes',
|
20
|
|
- action='store',
|
21
|
|
- dest='nclass',
|
22
|
|
- default = 3,
|
23
|
|
- help='Maximum number of classes per classtype',
|
24
|
|
- type="int",
|
25
|
|
- metavar="INT",
|
26
|
|
- ),
|
27
|
|
- make_option('--no-fieldgroup',
|
28
|
|
- action='store',
|
29
|
|
- dest='nofg',
|
30
|
|
- default = 10,
|
31
|
|
- help='Chances for a class to have no fieldgroup',
|
32
|
|
- type="int",
|
33
|
|
- metavar="INT",
|
34
|
|
- ),
|
35
|
|
- make_option('--no-types',
|
36
|
|
- action='store',
|
37
|
|
- dest='notype',
|
38
|
|
- default = 10,
|
39
|
|
- help='Chances for a class to have no types',
|
40
|
|
- type="int",
|
41
|
|
- metavar="INT",
|
42
|
|
- ),
|
43
|
|
- make_option('--max-types',
|
44
|
|
- action='store',
|
45
|
|
- dest='ntype',
|
46
|
|
- default = 8,
|
47
|
|
- help='Maximum number of types in a class',
|
48
|
|
- type="int",
|
49
|
|
- metavar="INT",
|
50
|
|
- ),
|
51
|
|
- make_option('--sel-opt-field',
|
52
|
|
- action='store',
|
53
|
|
- dest='seltype',
|
54
|
|
- default = 2,
|
55
|
|
- help='Chances for type to select an optionnal field',
|
56
|
|
- type="int",
|
57
|
|
- metavar="INT",
|
58
|
|
- ),
|
59
|
|
- make_option('--superiors',
|
60
|
|
- action='store',
|
61
|
|
- dest='ntypesuperiors',
|
62
|
|
- default = 2,
|
63
|
|
- help='Chances for a type to link with other types (superiors)',
|
64
|
|
- type="int",
|
65
|
|
- metavar="INT",
|
66
|
|
- ),
|
67
|
|
- make_option('--no-fields',
|
68
|
|
- action='store',
|
69
|
|
- dest='nofields',
|
70
|
|
- default = 10,
|
71
|
|
- help='Chances for a fieldgroup to be empty',
|
72
|
|
- type="int",
|
73
|
|
- metavar="INT",
|
74
|
|
- ),
|
75
|
|
- make_option('--max-fields',
|
76
|
|
- action='store',
|
77
|
|
- dest='nfields',
|
78
|
|
- default = 8,
|
79
|
|
- help='Maxmimum number of fields per fieldgroup',
|
80
|
|
- type="int",
|
81
|
|
- metavar="INT",
|
82
|
|
- ),
|
83
|
|
- make_option('--rel-to-type-attr',
|
84
|
|
- action='store',
|
85
|
|
- dest='rfields',
|
86
|
|
- default = 5,
|
87
|
|
- help='Maximum number of relation-to-type attribute fields',
|
88
|
|
- type="int",
|
89
|
|
- metavar="INT",
|
90
|
|
- ),
|
91
|
|
- make_option('--opt-field',
|
92
|
|
- action='store',
|
93
|
|
- dest='optfield',
|
94
|
|
- default = 2,
|
95
|
|
- help='Chances for a field to be optionnal',
|
96
|
|
- type="int",
|
97
|
|
- metavar="INT",
|
98
|
|
- ),
|
99
|
|
- make_option('-o',
|
100
|
|
- '--output',
|
101
|
|
- action='store',
|
102
|
|
- dest='output',
|
103
|
|
- default = 'random_me.json',
|
104
|
|
- help='json output file for the me',
|
105
|
|
- type="string",
|
106
|
|
- metavar="FILENAME",
|
107
|
|
- ),
|
108
|
|
- make_option('-d',
|
109
|
|
- '--output-dot',
|
110
|
|
- action='store',
|
111
|
|
- dest='dotout',
|
112
|
|
- default = False,
|
113
|
|
- help='graphviz output file for the me',
|
114
|
|
- type="string",
|
115
|
|
- metavar="FILENAME",
|
116
|
|
- ),
|
117
|
|
-
|
118
|
|
-
|
119
|
|
- )
|
120
|
|
- help = 'Randomly generate an EditorialModel'
|
121
|
|
-
|
122
|
|
- def handle(self, *args, **options):
|
123
|
|
- anames = ['classtype','nclass', 'nofg', 'notype', 'ntype', 'seltype', 'ntypesuperiors', 'nofields', 'nfields', 'optfield']
|
124
|
|
- chances = dict()
|
125
|
|
- for n in anames:
|
126
|
|
- chances[n] = options[n]
|
127
|
|
-
|
128
|
|
- bj = EmBackendJson(options['output'])
|
129
|
|
-
|
130
|
|
- em = RandomEm.random_em(EmBackendDummy())
|
131
|
|
- bj.save(em)
|
132
|
|
-
|
133
|
|
- if options['dotout']:
|
134
|
|
- gvb = EmBackendGraphviz(options['dotout'])
|
135
|
|
- gvb.save(em)
|
136
|
|
-
|
137
|
|
-
|