Changeset 4047
- Timestamp:
- 02/15/09 13:45:47 (4 years ago)
- Location:
- branch/NetworkInventory
- Files:
-
- 1 added
- 4 modified
-
umitDB/InventoryChanges.py (modified) (4 diffs)
-
umitInventory/HostDiscovery.py (modified) (3 diffs)
-
umitInventory/InventoryTree.py (modified) (4 diffs)
-
umitInventory/Utils.py (added)
-
umitInventory/Viewer.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/NetworkInventory/umitDB/InventoryChanges.py
r4046 r4047 250 250 ports_only = True 251 251 252 verb, plural = self.conjugate(info_changes, False)252 word, verb = self.conjugate(_("Port"), info_changes, False) 253 253 ports_str = ', '.join([str(p) for p in info_changes]) 254 254 this_port_diff = ' '.join([ 255 _("Port") + plural, ports_str, verb, _("changed info")])255 word, ports_str, verb, _("changed info")]) 256 256 host_diff = ''.join([host_diff, this_port_diff]) 257 257 … … 310 310 311 311 312 def conjugate(self, alist, toBe=True):312 def conjugate(self, word, alist, toBe=True): 313 313 """ 314 314 Do conjugation based on alist size. … … 322 322 if len(alist) > 1: 323 323 verb = verbs[0] 324 plural= _("s")324 word += _("s") 325 325 else: 326 326 verb = verbs[1] 327 plural = _("") 328 329 return verb, plural 327 328 return word, verb 330 329 331 330 … … 376 375 text = '' 377 376 if closed_ports: 378 verb, plural = self.conjugate(closed_ports)377 word, verb = self.conjugate(port_text, closed_ports) 379 378 closed_ports = ', '.join([str(p) for p in closed_ports]) 380 closed_ports = "%s %s %s %s %s %s." % (port_text, plural,379 closed_ports = "%s %s %s %s %s." % (word, 381 380 closed_ports, verb, closed_text, now_text) 382 381 383 382 if open_ports: 384 verb, plural = self.conjugate(open_ports)383 word, verb = self.conjugate(port_text, open_ports) 385 384 open_ports = ', '.join([str(p) for p in open_ports]) 386 open_ports = "%s %s %s %s %s %s." % (port_text, plural,385 open_ports = "%s %s %s %s %s." % (word, 387 386 open_ports, verb, open_text, now_text) 388 387 -
branch/NetworkInventory/umitInventory/HostDiscovery.py
r4034 r4047 30 30 from umitCore.Paths import Path 31 31 from umitCore.I18N import _ 32 33 from umitInventory.Utils import append_s 32 34 33 35 from higwidgets.higbuttons import HIGButton … … 323 325 self.target_model.clear() 324 326 self.hostdetect_btn.set_sensitive(False) 325 p = (self.scount > 1) and 's' or '' 327 self._adjust_target_label() 328 gobject.timeout_add(500, self._check_scans) 329 330 331 def _adjust_target_label(self): 332 """Update target_lbl according to the current scount (assumes that 333 scount > 0).""" 334 word = append_s(_("scan"), self.scount) 326 335 self.target_lbl.set_label( 327 _("Target list (%d scan%s running)") % (self.scount, p)) 328 gobject.timeout_add(500, self._check_scans) 336 _("Target list") + 337 (" (%d " % self.scount) + word + 338 _("running")) 329 339 330 340 … … 350 360 self.scount -= 1 351 361 if self.scount: 352 p = (self.scount > 1) and 's' or '' 353 self.target_lbl.set_label( 354 _("Target list (%d scan%s running)") % (self.scount, p)) 362 self._adjust_target_label() 355 363 356 364 # clean up temp files -
branch/NetworkInventory/umitInventory/InventoryTree.py
r4034 r4047 38 38 from umitInventory.InventoryLoad import InventoryLoad 39 39 from umitInventory.InventoryCommonDialog import NoScheduleDlg 40 from umitInventory.Utils import append_s 40 41 41 42 INVENTORY_INFO = _("Info") … … 52 53 factory.add(NI_INVENTORY_ROOT_ICON, gtk.IconSet(pixbuf)) 53 54 factory.add_default() 54 55 def get_plural(count):56 if count == 0 or count > 1:57 return _("s")58 else:59 return _("")60 55 61 56 class InventoryTree(gtk.Notebook): … … 269 264 self.running_scans[scan] = inv 270 265 running_scans = len(self.running_scans) 271 plural = get_plural(running_scans)272 266 self.daddy._write_statusbar(("%d " % running_scans) + 273 _("scan") + plural+ _(" running"))267 append_s(_("scan"), running_scans) + _(" running")) 274 268 275 269 def _check_scans(self): … … 322 316 323 317 running_scans = len(self.running_scans) 324 plural = get_plural(running_scans)318 word = append_s(_("scan"), running_scans) 325 319 self.daddy._write_statusbar( 326 ("%d " % running_scans) + _("scan") + plural+ _(" running"))320 ("%d " % running_scans) + word + _(" running")) 327 321 328 322 if not self.running_scans: -
branch/NetworkInventory/umitInventory/Viewer.py
r4034 r4047 55 55 from umitInventory.About import About 56 56 from umitInventory.InventoryException import NoInventory 57 from umitInventory.Utils import append_s 58 57 59 58 60 umitdb = Path.umitdb_ng … … 543 545 # layout 544 546 matches = len(args[1]) 545 if matches > 1 or matches == 0: 546 plural = _("s") 547 else: 548 plural = _("") 547 word = append_s(_("result"), matches) 549 548 upper_title = gtk.Label() 550 549 upper_title.set_markup( 551 ("<b>%d " % plural) + _("result") + plural+ _(" found.") +550 ("<b>%d " % matches) + word + _(" found.") + 552 551 "</b>") 553 552 hutbox = HIGHBox()
