Пример #1
0
class Star(Record):
    hip_id = Property(isa=int, required=True,
                      coerce=fix_id,
                      check=lambda i: 0 < i < 120000)
    name = Property(isa=str)
    spectral_type = Property(isa=str)
    designations = DictProperty(of=basestring)
    coordinates = DictProperty(of=list_of(basestring))
Пример #2
0
    def test_cast_collection(self):
        RecordList = list_of(Record)
        casted = VisitorPattern.cast(RecordList, [{}, {}])
        self.assertIsInstance(casted[0], Record)
        self.assertIsInstance(casted, RecordList)

        empty_casted = VisitorPattern.cast(RecordList, [])
        self.assertIsInstance(empty_casted, RecordList)
Пример #3
0
    def test_cast_collection(self):
        RecordList = list_of(Record)
        casted = VisitorPattern.cast(RecordList, [{}, {}])
        self.assertIsInstance(casted[0], Record)
        self.assertIsInstance(casted, RecordList)

        empty_casted = VisitorPattern.cast(RecordList, [])
        self.assertIsInstance(empty_casted, RecordList)
Пример #4
0
 class Pilcrow(Record):
     bar = ListProperty(of=Octothorpe)
     foo = Property(isa=Caret)
     baz = Property()
     quux = DictProperty(of=str)
     frop = DictProperty(of=list_of(unicode))
Пример #5
0
 class FakeSite(JsonRecord):
     slug = Property()
     _custom_tags = DictProperty(of=list_of(str))
Пример #6
0
 def auto_upgrade_list(cls, thing):
     if len(thing) and isinstance(thing[0], dict):
         return list_of(NCAutoJsonRecord)(thing)
     else:
         return thing
Пример #7
0
 def auto_upgrade_list(cls, thing):
     if len(thing) and isinstance(thing[0], dict):
         return list_of(NCAutoJsonRecord)(thing)
     else:
         return thing