@@ 45-70 (lines=26) @@ | ||
42 | @yorm.attr(falsey=Boolean) |
|
43 | @yorm.attr(number_int=Integer) |
|
44 | @yorm.attr(number_real=Float) |
|
45 | @yorm.attr(object=EmptyDictionary) |
|
46 | @yorm.attr(string=String) |
|
47 | @yorm.attr(truthy=Boolean) |
|
48 | @yorm.sync("tmp/{self.category}/{self.name}.yml") |
|
49 | class SampleStandardDecorated: |
|
50 | """Sample class using standard attribute types.""" |
|
51 | ||
52 | def __init__(self, name, category='default'): |
|
53 | self.name = name |
|
54 | self.category = category |
|
55 | # https://docs.python.org/3.4/library/json.html#json.JSONDecoder |
|
56 | self.object = {} |
|
57 | self.array = [] |
|
58 | self.string = "" |
|
59 | self.number_int = 0 |
|
60 | self.number_real = 0.0 |
|
61 | self.truthy = True |
|
62 | self.falsey = False |
|
63 | self.null = None |
|
64 | ||
65 | def __repr__(self): |
|
66 | return "<decorated {}>".format(id(self)) |
|
67 | ||
68 | ||
69 | @yorm.attr(label=String) |
|
70 | @yorm.attr(status=Boolean) |
|
71 | class StatusDictionary(Dictionary): |
|
72 | """Sample dictionary container.""" |
|
73 |
@@ 27-52 (lines=26) @@ | ||
24 | @yorm.attr(array=IntegerList) |
|
25 | @yorm.attr(false=Boolean) |
|
26 | @yorm.attr(number_int=Integer) |
|
27 | @yorm.attr(number_real=Float) |
|
28 | @yorm.attr(object=EmptyDictionary) |
|
29 | @yorm.attr(string=String) |
|
30 | @yorm.attr(true=Boolean) |
|
31 | @yorm.sync("tmp/path/to/{self.category}/{self.name}.yml") |
|
32 | class SampleStandardDecorated: |
|
33 | """Sample class using standard attribute types.""" |
|
34 | ||
35 | def __init__(self, name, category='default'): |
|
36 | self.name = name |
|
37 | self.category = category |
|
38 | # https://docs.python.org/3.4/library/json.html#json.JSONDecoder |
|
39 | self.object = {} |
|
40 | self.array = [] |
|
41 | self.string = "" |
|
42 | self.number_int = 0 |
|
43 | self.number_real = 0.0 |
|
44 | self.true = True |
|
45 | self.false = False |
|
46 | self.null = None |
|
47 | ||
48 | def __repr__(self): |
|
49 | return "<decorated {}>".format(id(self)) |
|
50 | ||
51 | ||
52 | # TESTS ######################################################################## |
|
53 | ||
54 | ||
55 | class TestCreate: |