コード例 #1
0
ファイル: common.py プロジェクト: invisig0th/synapse
def reqStorDict(x):
    '''
    Raises BadStorValu if any value in the dict is not compatible
    with being stored in a cortex.
    '''
    for k, v in x.items():
        if not canstor(v):
            raise BadStorValu(name=k, valu=v)
コード例 #2
0
def reqstor(name, valu):
    '''
    Check to see if a value can be stored in a Cortex.

    Args:
        name (str): Property name.
        valu: Value to check.

    Returns:
        The valu is returned if it can be stored in a Cortex.

    Raises:
        BadPropValu if the value is not Cortex storable.
    '''
    if not canstor(valu):
        raise BadPropValu(name=name, valu=valu)
    return valu
コード例 #3
0
    def test_compat_canstor(self):
        self.assertTrue(0xf0f0)
        self.assertTrue(0xf0f0f0f0f0f0)
        self.assertTrue(s_compat.canstor('asdf'))
        self.assertTrue(s_compat.canstor(u'asdf'))

        self.assertFalse(s_compat.canstor(True))
        self.assertFalse(s_compat.canstor(('asdf', )))
        self.assertFalse(s_compat.canstor([
            'asdf',
        ]))
        self.assertFalse(s_compat.canstor({'asdf': True}))