本文整理汇总了Python中qgis.core.QgsStringReplacementCollection类的典型用法代码示例。如果您正苦于以下问题:Python QgsStringReplacementCollection类的具体用法?Python QgsStringReplacementCollection怎么用?Python QgsStringReplacementCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsStringReplacementCollection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSaveRestore
def testSaveRestore(self):
""" test saving and restoring collections """
c = QgsStringReplacementCollection([QgsStringReplacement('aa', '11', False, False),
QgsStringReplacement('bb', '22', True, True)])
doc = QDomDocument("testdoc")
elem = doc.createElement("replacements")
c.writeXml(elem, doc)
c2 = QgsStringReplacementCollection()
c2.readXml(elem)
self.assertEqual(c2.replacements(), c.replacements())
示例2: testBasic
def testBasic(self):
""" basic QgsStringReplacementCollection tests"""
list = [QgsStringReplacement('aa', '11'),
QgsStringReplacement('bb', '22')]
c = QgsStringReplacementCollection(list)
self.assertEqual(c.replacements(), list)
示例3: testReplacements
def testReplacements(self):
""" test replacing using collection of replacements """
c = QgsStringReplacementCollection()
c.setReplacements([QgsStringReplacement('aa', '11'),
QgsStringReplacement('bb', '22')])
self.assertEqual(c.process('here aa bb is aa string bb'), 'here 11 22 is 11 string 22')
self.assertEqual(c.process('no matches'), 'no matches')
self.assertEqual(c.process(''), '')
# test replacements are done in order
c.setReplacements([QgsStringReplacement('aa', '11'),
QgsStringReplacement('11', '22')])
self.assertEqual(c.process('string aa'), 'string 22')
# no replacements
c.setReplacements([])
self.assertEqual(c.process('string aa'), 'string aa')