python类NoneType()的实例源码

ble_driver.py 文件源码 项目:pc-ble-driver-py 作者: NordicSemiconductor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, vs_uuid_base=None, uuid_type=None):
        assert isinstance(vs_uuid_base, (list, NoneType)), 'Invalid argument type'
        assert isinstance(uuid_type, (int, long, NoneType)), 'Invalid argument type'
        if (vs_uuid_base is None) and uuid_type is None:
            self.base   = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
                           0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB]
            self.type   = driver.BLE_UUID_TYPE_BLE

        else:
            self.base   = vs_uuid_base
            self.type   = uuid_type
ble_driver.py 文件源码 项目:pc-ble-driver-py 作者: NordicSemiconductor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def ble_gap_conn_param_update(self, conn_handle, conn_params):
        assert isinstance(conn_params, (BLEGapConnParams, NoneType)), 'Invalid argument type'
        if conn_params:
            conn_params=conn_params.to_c()
        return driver.sd_ble_gap_conn_param_update(self.rpc_adapter, conn_handle, conn_params)
ble_driver.py 文件源码 项目:pc-ble-driver-py 作者: NordicSemiconductor 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def ble_gap_authenticate(self, conn_handle, sec_params):
        assert isinstance(sec_params, (BLEGapSecParams, NoneType)), 'Invalid argument type'
        return driver.sd_ble_gap_authenticate(self.rpc_adapter,
                                              conn_handle,
                                              sec_params.to_c() if sec_params else None)
ble_driver.py 文件源码 项目:pc-ble-driver-py 作者: NordicSemiconductor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def ble_gattc_prim_srvc_disc(self, conn_handle, srvc_uuid, start_handle):
        assert isinstance(srvc_uuid, (BLEUUID, NoneType)), 'Invalid argument type'
        return driver.sd_ble_gattc_primary_services_discover(self.rpc_adapter,
                                                             conn_handle,
                                                             start_handle,
                                                             srvc_uuid.to_c() if srvc_uuid else None)
abc.py 文件源码 项目:xiaodi 作者: shenaishiren 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def write_success(self, data=None, finish=True):
        assert isinstance(data, (types.NoneType, dict)), 'data must be NoneType or dict'
        self._async_write(dict((data or {}), **{'status': 'success'}), finish=finish)
models.py 文件源码 项目:py2cpp 作者: mugwort-rc 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def create(field, node, parent=None):
        item = ASTAttrTreeItem(field, node, parent)
        if isinstance(node, list):
            for child in node:
                item.children.append(ASTTreeItem.create(child, parent=item))
        elif not isinstance(node, (str, int, float, types.NoneType)):
            item.children.append(ASTTreeItem.create(node, parent=item))
        return item
encoding.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def is_protected_type(obj):
    """Determine if the object instance is of a protected type.

    Objects of protected types are preserved as-is when passed to
    force_unicode(strings_only=True).
    """
    return isinstance(obj, (
        six.integer_types +
        (types.NoneType,
         datetime.datetime, datetime.date, datetime.time,
         float, Decimal))
    )
fetchTracks.py 文件源码 项目:MusicML 作者: tonyhong272 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def save_sqlite(track_info):
    [track, trackInfoEchoNest, trackInfoLastFM] = track_info
    convert_type_dict = {float:'REAL', unicode:'TEXT', int:'INTEGER', str:'TEXT'}

    EN_key_list = trackInfoEchoNest.keys()
    LF_key_list = trackInfoLastFM.keys()

    table_columns = []
    column_names = []
    question_mark_sign = []
    for key in EN_key_list:
        if type(trackInfoEchoNest[key]) != types.NoneType:
            column_names.append('EN_' + key)
            table_columns1 = ' '.join(['EN_' + key, convert_type_dict[type(trackInfoEchoNest[key])]])
            table_columns.append(table_columns1)
            question_mark_sign.append('?')
        else:
            trackInfoEchoNest.pop(key)

    for key in LF_key_list:
        if type(trackInfoLastFM[key]) != types.NoneType:
            column_names.append('LF_' + key)
            table_columns1 = ' '.join(['LF_' + key, convert_type_dict[type(trackInfoLastFM[key])]])
            table_columns.append(table_columns1)
            question_mark_sign.append('?')
        else:
            trackInfoLastFM.pop(key)

    con = lite.connect('musicdata.db')
    with con:
        cur = con.cursor()
        #cur.execute("DROP TABLE IF EXISTS BoardEntries")
        cur.execute("SELECT ROWID FROM TrackEntries WHERE EN_title = ? and EN_artist_name = ?", (trackInfoEchoNest['title'],trackInfoEchoNest['artist_name']))
        existingEntry=cur.fetchone()
        if existingEntry is None:
            print('saving into database %s, %s'%(trackInfoEchoNest['title'], trackInfoEchoNest['artist_name']))
            single_entry = tuple([str(time.strftime("%Y-%m-%d %H:%M:%S")), track['title'], track['artist']] + trackInfoEchoNest.values() + trackInfoLastFM.values())
            cur.execute('INSERT OR IGNORE INTO TrackEntries(ID, EntryDate, SearchTitle, SearchArtist, ' + ', '.join(column_names) + ') VALUES (NULL, ?,?,?, ' + ', '.join(question_mark_sign)+')', single_entry)
        else:
            print('found in database %s, %s'%(trackInfoEchoNest['title'], trackInfoEchoNest['artist_name']))
    con.close()
encoding.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def is_protected_type(obj):
    """Determine if the object instance is of a protected type.

    Objects of protected types are preserved as-is when passed to
    force_unicode(strings_only=True).
    """
    return isinstance(obj, (
        six.integer_types +
        (types.NoneType,
         datetime.datetime, datetime.date, datetime.time,
         float, Decimal))
    )
test_descr.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_unsubclassable_types(self):
        with self.assertRaises(TypeError):
            class X(types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(object, types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(types.NoneType, object):
                pass
        class O(object):
            pass
        with self.assertRaises(TypeError):
            class X(O, types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(types.NoneType, O):
                pass

        class X(object):
            pass
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType,
        with self.assertRaises(TypeError):
            X.__bases__ = object, types.NoneType
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType, object
        with self.assertRaises(TypeError):
            X.__bases__ = O, types.NoneType
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType, O
test_descr.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_unsubclassable_types(self):
        with self.assertRaises(TypeError):
            class X(types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(object, types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(types.NoneType, object):
                pass
        class O(object):
            pass
        with self.assertRaises(TypeError):
            class X(O, types.NoneType):
                pass
        with self.assertRaises(TypeError):
            class X(types.NoneType, O):
                pass

        class X(object):
            pass
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType,
        with self.assertRaises(TypeError):
            X.__bases__ = object, types.NoneType
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType, object
        with self.assertRaises(TypeError):
            X.__bases__ = O, types.NoneType
        with self.assertRaises(TypeError):
            X.__bases__ = types.NoneType, O
OpenOPC.py 文件源码 项目:opc-rest-api 作者: matzpersson 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def properties(self, tags, id=None):
      """Return list of property tuples (id, name, value) for the specified tag(s) """

      if type(tags) not in (types.ListType, types.TupleType) and type(id) not in (types.NoneType, types.ListType, types.TupleType):
         single = True
      else:
         single = False

      props = self.iproperties(tags, id)

      if single:
         return list(props)[0]
      else:
         return list(props)
util.py 文件源码 项目:download-manager 作者: thispc 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def coerce_cache_params(params):
    rules = [
        ('data_dir', (str, types.NoneType), "data_dir must be a string "
         "referring to a directory."),
        ('lock_dir', (str, types.NoneType), "lock_dir must be a string referring to a "
         "directory."),
        ('type', (str,), "Cache type must be a string."),
        ('enabled', (bool, types.NoneType), "enabled must be true/false "
         "if present."),
        ('expire', (int, types.NoneType), "expire must be an integer representing "
         "how many seconds the cache is valid for"),
        ('regions', (list, tuple, types.NoneType), "Regions must be a "
         "comma seperated list of valid regions")
    ]
    return verify_rules(params, rules)
encoding.py 文件源码 项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def is_protected_type(obj):
    """Determine if the object instance is of a protected type.

    Objects of protected types are preserved as-is when passed to
    force_unicode(strings_only=True).
    """
    return isinstance(obj, (
        six.integer_types +
        (types.NoneType,
         datetime.datetime, datetime.date, datetime.time,
         float, Decimal))
    )
encoding.py 文件源码 项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def is_protected_type(obj):
    """Determine if the object instance is of a protected type.

    Objects of protected types are preserved as-is when passed to
    force_unicode(strings_only=True).
    """
    return isinstance(obj, (
        six.integer_types +
        (types.NoneType,
         datetime.datetime, datetime.date, datetime.time,
         float, Decimal))
    )
serializers.py 文件源码 项目:esdc-ce 作者: erigones 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _is_protected_type(obj):
    """
    True if the object is a native data type that does not need to be serialized further.
    """
    return isinstance(obj, six.string_types + six.integer_types + (
        types.NoneType,
        datetime.datetime, datetime.date, datetime.time,
        float, Decimal,
    ))
audio.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def comment(self, comment=None):
        """Modify or return a string comment."""
        assert isinstance(comment, (basestring, types.NoneType)), "A comment is a string"

        if comment is not None:
            self._comment = comment

        return self._comment
geometry.py 文件源码 项目:crime-analysis-toolbox 作者: Esri 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def X(self, value):
        """sets the X coordinate"""
        if isinstance(value, (int, float,
                              long, types.NoneType)):
            self._x = value
    #----------------------------------------------------------------------
geometry.py 文件源码 项目:crime-analysis-toolbox 作者: Esri 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def Y(self, value):
        """ sets the Y coordinate """
        if isinstance(value, (int, float,
                              long, types.NoneType)):
            self._y = value
    #----------------------------------------------------------------------
geometry.py 文件源码 项目:crime-analysis-toolbox 作者: Esri 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def Z(self, value):
        """ sets the Z coordinate """
        if isinstance(value, (int, float,
                              long, types.NoneType)):
            self._z = value
    #----------------------------------------------------------------------


问题


面经


文章

微信
公众号

扫码关注公众号