comparison markup/core.py @ 161:a25f9fc5787d

Various docstring additions and other cosmetic changes.
author cmlenz
date Wed, 16 Aug 2006 22:32:31 +0000
parents f7fb556f2678
children f1ac0510d392
comparison
equal deleted inserted replaced
160:faea6db52ef1 161:a25f9fc5787d
214 if attr == name: 214 if attr == name:
215 return value 215 return value
216 return default 216 return default
217 217
218 def remove(self, name): 218 def remove(self, name):
219 """Removes the attribute with the specified name. 219 """Remove the attribute with the specified name.
220 220
221 If no such attribute is found, this method does nothing. 221 If no such attribute is found, this method does nothing.
222 """ 222 """
223 for idx, (attr, _) in enumerate(self): 223 for idx, (attr, _) in enumerate(self):
224 if attr == name: 224 if attr == name:
225 del self[idx] 225 del self[idx]
226 break 226 break
227 227
228 def set(self, name, value): 228 def set(self, name, value):
229 """Sets the specified attribute to the given value. 229 """Set the specified attribute to the given value.
230 230
231 If an attribute with the specified name is already in the list, the 231 If an attribute with the specified name is already in the list, the
232 value of the existing entry is updated. Otherwise, a new attribute is 232 value of the existing entry is updated. Otherwise, a new attribute is
233 appended to the end of the list. 233 appended to the end of the list.
234 """ 234 """
238 break 238 break
239 else: 239 else:
240 self.append((QName(name), value)) 240 self.append((QName(name), value))
241 241
242 def totuple(self): 242 def totuple(self):
243 """Return the attributes as a markup event.
244
245 The returned event is a TEXT event, the data is the value of all
246 attributes joined together.
247 """
243 return TEXT, u''.join([x[1] for x in self]), (None, -1, -1) 248 return TEXT, u''.join([x[1] for x in self]), (None, -1, -1)
244 249
245 250
246 def plaintext(text, keeplinebreaks=True): 251 def plaintext(text, keeplinebreaks=True):
247 """Returns the text as a `unicode` string with all entities and tags 252 """Returns the text as a `unicode` string with all entities and tags
Copyright (C) 2012-2017 Edgewall Software