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


Python core.QgsStringReplacement类代码示例

本文整理汇总了Python中qgis.core.QgsStringReplacement的典型用法代码示例。如果您正苦于以下问题:Python QgsStringReplacement类的具体用法?Python QgsStringReplacement怎么用?Python QgsStringReplacement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testBasic

    def testBasic(self):
        """ basic tests for QgsStringReplacement"""
        r = QgsStringReplacement('match', 'replace')
        self.assertEqual(r.match(), 'match')
        self.assertEqual(r.replacement(), 'replace')

        r = QgsStringReplacement('match', 'replace', True, True)
        self.assertTrue(r.wholeWordOnly())
        self.assertTrue(r.caseSensitive())
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: testSaveRestore

 def testSaveRestore(self):
     """ test saving/restoring replacement to map"""
     r1 = QgsStringReplacement('a', 'b', True, True)
     props = r1.properties()
     r2 = QgsStringReplacement.fromProperties(props)
     self.assertEqual(r1, r2)
     r1 = QgsStringReplacement('a', 'b', False, False)
     props = r1.properties()
     r2 = QgsStringReplacement.fromProperties(props)
     self.assertEqual(r1, r2)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例3: testReplace

    def testReplace(self):
        """ test applying replacements"""

        # case insensitive
        r = QgsStringReplacement('match', 'replace', False, False)
        self.assertEqual(r.process('one MaTch only'), 'one replace only')
        self.assertEqual(r.process('more then one MaTch here match two'), 'more then one replace here replace two')
        self.assertEqual(r.process('match start and end MaTch'), 'replace start and end replace')
        self.assertEqual(r.process('no hits'), 'no hits')
        self.assertEqual(r.process('some exmatches here'), 'some exreplacees here')
        self.assertEqual(r.process(''), '')

        # case sensitive
        r = QgsStringReplacement('match', 'replace', True, False)
        self.assertEqual(r.process('one MaTch only'), 'one MaTch only')
        self.assertEqual(r.process('one match only'), 'one replace only')

        # whole word only, case insensitive
        r = QgsStringReplacement('match', 'replace', False, True)
        self.assertEqual(r.process('some exmatches here'), 'some exmatches here')
        self.assertEqual(r.process('some match here'), 'some replace here')
        self.assertEqual(r.process('some exmatches MaTch here'), 'some exmatches replace here')
        self.assertEqual(r.process('some match maTCh here'), 'some replace replace here')
        self.assertEqual(r.process('some -match. here'), 'some -replace. here')
        self.assertEqual(r.process('match here'), 'replace here')
        self.assertEqual(r.process('some match'), 'some replace')

        # whole word only, case sensitive
        r = QgsStringReplacement('match', 'replace', True, True)
        self.assertEqual(r.process('some exmatches here'), 'some exmatches here')
        self.assertEqual(r.process('some match here'), 'some replace here')
        self.assertEqual(r.process('some exmatches MaTch here'), 'some exmatches MaTch here')
        self.assertEqual(r.process('some match maTCh here'), 'some replace maTCh here')
开发者ID:,项目名称:,代码行数:33,代码来源:


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