コード例 #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
ファイル: test_visitor.py プロジェクト: mattrowe/normalize
    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
ファイル: test_compare.py プロジェクト: wyguy444/normalize
 class FakeSite(JsonRecord):
     slug = Property()
     _custom_tags = DictProperty(of=list_of(str))
コード例 #6
0
ファイル: json.py プロジェクト: saraducks/normalize
 def auto_upgrade_list(cls, thing):
     if len(thing) and isinstance(thing[0], dict):
         return list_of(NCAutoJsonRecord)(thing)
     else:
         return thing
コード例 #7
0
ファイル: json.py プロジェクト: hearsaycorp/normalize
 def auto_upgrade_list(cls, thing):
     if len(thing) and isinstance(thing[0], dict):
         return list_of(NCAutoJsonRecord)(thing)
     else:
         return thing