本文整理匯總了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')