当前位置: 首页>>代码示例>>Python>>正文


Python GLib.utf8_normalize方法代码示例

本文整理汇总了Python中gi.repository.GLib.utf8_normalize方法的典型用法代码示例。如果您正苦于以下问题:Python GLib.utf8_normalize方法的具体用法?Python GLib.utf8_normalize怎么用?Python GLib.utf8_normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.utf8_normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_songs_with_any_match

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import utf8_normalize [as 别名]
    def get_songs_with_any_match(name):
        name = Tracker.sparql_escape_string(GLib.utf8_normalize(GLib.utf8_casefold(name, -1), -1, GLib.NormalizeMode.NFKD))
        query = """
            {
                SELECT DISTINCT
                    ?song
                WHERE {
                    ?song a nmm:MusicPiece .
                    BIND(tracker:normalize(nie:title(nmm:musicAlbum(?song)), 'nfkd') AS ?match1) .
                    BIND(tracker:normalize(nmm:artistName(nmm:performer(?song)), 'nfkd') AS ?match2) .
                    BIND(tracker:normalize(nie:title(?song), 'nfkd') AS ?match3) .
                    BIND(tracker:normalize(nmm:composer(?song), 'nfkd') AS ?match4) .
                    FILTER (
                        CONTAINS(tracker:case-fold(tracker:unaccent(?match1)), "%(name)s") ||
                        CONTAINS(tracker:case-fold(?match1), "%(name)s") ||
                        CONTAINS(tracker:case-fold(tracker:unaccent(?match2)), "%(name)s") ||
                        CONTAINS(tracker:case-fold(?match2), "%(name)s") ||
                        CONTAINS(tracker:case-fold(tracker:unaccent(?match3)), "%(name)s") ||
                        CONTAINS(tracker:case-fold(?match3), "%(name)s") ||
                        CONTAINS(tracker:case-fold(tracker:unaccent(?match4)), "%(name)s") ||
                        CONTAINS(tracker:case-fold(?match4), "%(name)s")
                    )
                }
            }
            """.replace('\n', ' ').strip() % {'name': name}

        return Query.songs(query)
开发者ID:GNOME,项目名称:gnome-music,代码行数:29,代码来源:query.py

示例2: _normalize_and_hash

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import utf8_normalize [as 别名]
    def _normalize_and_hash(self, input_str):
        normalized = " "

        if input_str and len(input_str) > 0:
            normalized = self._strip_invalid_entities(input_str)
            normalized = GLib.utf8_normalize(normalized, -1, GLib.NormalizeMode.NFKD)
            normalized = normalized.lower()

        return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, normalized, -1)
开发者ID:sumansai14,项目名称:gnome-music,代码行数:11,代码来源:albumArtCache.py

示例3: normalizeAndHash

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import utf8_normalize [as 别名]
    def normalizeAndHash(self, input_str):
        normalized = " "

        if input_str is not None and input_str.length() > 0:
            normalized = self.stripInvalidEntities(input_str)
            normalized = GLib.utf8_normalize(normalized, -1,
                                             GLib.NormalizeMode.NFKD)
            normalized = normalized.toLowerCase()

        return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5,
                                                normalized, -1)
开发者ID:gquintard,项目名称:gnome-music-1,代码行数:13,代码来源:albumArtCache.py


注:本文中的gi.repository.GLib.utf8_normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。